Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-06-12 18:40:47
Exec Total Coverage
Lines: 1753 4157 42.2%
Functions: 130 328 39.6%
Branches: 945 2698 35.0%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 #include <math.h>
18 #include <map>
19 #include <filesystem>
20 #include <ctype.h>
21 #include <sstream>
22 #include "base/zc_alleg.h"
23 #include "gamedata.h"
24 #include "zc/zc_init.h"
25 #include "init.h"
26 #include "zc/replay.h"
27 #include "zc/cheats.h"
28 #include "zc/render.h"
29 #include "base/zc_math.h"
30 #include "base/zapp.h"
31 #include "dialog/cheatkeys.h"
32 #include "metadata/metadata.h"
33 #include "zc/zelda.h"
34 #include "tiles.h"
35 #include "base/colors.h"
36 #include "pal.h"
37 #include "base/zsys.h"
38 #include "qst.h"
39 #include "zc/zc_sys.h"
40 #include "play_midi.h"
41 #include "jwin_a5.h"
42 #include "base/jwinfsel.h"
43 #include "base/gui.h"
44 #include "midi.h"
45 #include "subscr.h"
46 #include "zc/maps.h"
47 #include "sprite.h"
48 #include "zc/guys.h"
49 #include "zc/hero.h"
50 #include "zc/title.h"
51 #include "particles.h"
52 #include "zconsole.h"
53 #include "zc/ffscript.h"
54 #include "dialog/info.h"
55 #include "dialog/alert.h"
56 #include "zc/combos.h"
57 #include <fmt/format.h>
58
59 #ifdef __EMSCRIPTEN__
60 #include "base/emscripten_utils.h"
61 #endif
62
63 extern FFScript FFCore;
64 extern bool Playing;
65 int32_t sfx_voice[WAV_COUNT];
66 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
67 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
68
69 extern byte monochrome_console;
70
71 extern HeroClass Hero;
72 extern FFScript FFCore;
73 extern ZModule zcm;
74 extern zcmodule moduledata;
75 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
76 extern particle_list particles;
77 extern int32_t loadlast;
78 extern word passive_subscreen_doscript;
79 extern bool passive_subscreen_waitdraw;
80 extern char *sfx_string[WAV_COUNT];
81 byte use_dwm_flush;
82 byte use_save_indicator;
83 byte midi_patch_fix;
84 bool midi_paused=false;
85 int32_t paused_midi_pos = 0;
86 byte midi_suspended = 0;
87 byte callback_switchin = 0;
88 byte zc_192b163_warp_compatibility;
89 char modulepath[2048];
90 bool epilepsyFlashReduction;
91 signed char pause_in_background_menu_init = 0;
92 byte pause_in_background = 0;
93 bool is_sys_pal = false;
94 static bool load_control_called_this_frame;
95 extern PALETTE* hw_palette;
96 extern bool update_hw_pal;
97 extern const char* dmaplist(int32_t index, int32_t* list_size);
98 int32_t getnumber(const char *prompt,int32_t initialval);
99
100 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
101 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
102 //extern byte refresh_select_screen;
103 //extern movingblock mblock2; //mblock[4]?
104 //extern int32_t db;
105
106 static const char *ZC_str = "Zelda Classic";
107 extern char save_file_name[1024];
108 #if defined(ALLEGRO_WINDOWS)
109 const char *qst_dir_name = "win_qst_dir";
110 static const char *qst_module_name = "current_module";
111 #elif defined(ALLEGRO_LINUX)
112 const char *qst_dir_name = "linux_qst_dir";
113 static const char *qst_module_name = "current_module";
114 #elif defined(__APPLE__)
115 const char *qst_dir_name = "osx_qst_dir";
116 static const char *qst_module_name = "current_module";
117 #endif
118 #ifdef ALLEGRO_LINUX
119 static const char *samplepath = "samplesoundset/patches.dat";
120 #endif
121 char qst_files_path[2048];
122
123 #ifdef _MSC_VER
124 #define getcwd _getcwd
125 #endif
126
127 bool rF11();
128 bool rI();
129 bool rQ();
130 bool zc_key_pressed();
131
132 #ifdef _WIN32
133
134 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
135 extern "C"
136 {
137 typedef HRESULT(WINAPI *t_DwmFlush)();
138 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
139 }
140
141 void do_DwmFlush()
142 {
143 static HMODULE shell = LoadLibrary("dwmapi.dll");
144
145 if(!shell)
146 return;
147
148 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
149 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
150
151 BOOL enabled;
152 isEnabled(&enabled);
153
154 if(isEnabled)
155 flush();
156 }
157
158 #endif // _WIN32
159
160 82835 bool flash_reduction_enabled(bool check_qr)
161 {
162
4/4
✓ Branch 0 taken 80614 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 80158 times.
✓ Branch 3 taken 82379 times.
82835 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
163 }
164
165 // Dialogue largening
166 void large_dialog(DIALOG *d)
167 {
168 large_dialog(d, 1.5);
169 }
170
171 void large_dialog(DIALOG *d, float RESIZE_AMT)
172 {
173 if(!d[0].d1)
174 {
175 d[0].d1 = 1;
176 int32_t oldwidth = d[0].w;
177 int32_t oldheight = d[0].h;
178 int32_t oldx = d[0].x;
179 int32_t oldy = d[0].y;
180 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
181 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
182 d[0].w = int32_t(d[0].w*RESIZE_AMT);
183 d[0].h = int32_t(d[0].h*RESIZE_AMT);
184
185 for(int32_t i=1; d[i].proc !=NULL; i++)
186 {
187 // Place elements horizontally
188 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
189 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
190
191 if(d[i].proc != d_stringloader)
192 {
193 if(d[i].proc==d_bitmap_proc)
194 {
195 d[i].w *= 2;
196 }
197 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
198 }
199
200 // Place elements vertically
201 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
202 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
203
204 // Vertically resize elements
205 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
206 {
207 d[i].h = int32_t((double)d[i].h*1.5);
208 }
209 else if(d[i].proc == jwin_droplist_proc)
210 {
211 d[i].y += int32_t((double)d[i].h*0.25);
212 d[i].h = int32_t((double)d[i].h*1.25);
213 }
214 else if(d[i].proc==d_bitmap_proc)
215 {
216 d[i].h *= 2;
217 }
218 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
219
220 // Fix frames
221 if(d[i].proc == jwin_frame_proc)
222 {
223 d[i].x++;
224 d[i].y++;
225 d[i].w-=4;
226 d[i].h-=4;
227 }
228 }
229 }
230
231 for(int32_t i=1; d[i].proc!=NULL; i++)
232 {
233 if(d[i].proc==jwin_slider_proc)
234 continue;
235
236 // Bigger font
237 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
238
239 if(!d[i].dp2 && bigfontproc)
240 {
241 d[i].dp2 = get_zc_font(font_lfont_l);
242 }
243 else if(!bigfontproc)
244 {
245 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
246 }
247
248 // Make checkboxes work
249 if(d[i].proc == jwin_check_proc)
250 d[i].proc = jwin_checkfont_proc;
251 else if(d[i].proc == jwin_radio_proc)
252 d[i].proc = jwin_radiofont_proc;
253 }
254
255 jwin_center_dialog(d);
256 }
257
258
259 /**********************************/
260 /******** System functions ********/
261 /**********************************/
262
263 static char cfg_sect[] = "zeldadx"; //We need to rename this.
264 static char ctrl_sect[] = "Controls";
265 static char sfx_sect[] = "Volume";
266
267 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
268 {
269 return D_O_K;
270 }
271
272 bool is_reserved_key(int c)
273 {
274 switch(c)
275 {
276 case KEY_ESC:
277 return true;
278 }
279 return false;
280 }
281 bool is_reserved_keycombo(int c, int modflag)
282 {
283 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
284 return true;
285 return false;
286 }
287 bool checkcheat(Cheat cheat)
288 {
289 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
290 return true; //Main key pressed
291 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
292 return true; //Alt key pressed
293 return false;
294 }
295 34 void load_default_cheatkeys()
296 {
297 34 memset(cheatkeys, 0, sizeof(cheatkeys));
298 34 cheatkeys[Cheat::Life][0] = KEY_H;
299 34 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
300 34 cheatkeys[Cheat::Magic][0] = KEY_M;
301 34 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
302 34 cheatkeys[Cheat::Rupies][0] = KEY_R;
303 34 cheatkeys[Cheat::Bombs][0] = KEY_B;
304 34 cheatkeys[Cheat::Arrows][0] = KEY_A;
305 34 cheatkeys[Cheat::Clock][0] = KEY_I;
306 34 cheatkeys[Cheat::Walls][0] = KEY_F11;
307 34 cheatkeys[Cheat::Fast][0] = KEY_Q;
308 34 cheatkeys[Cheat::Light][0] = KEY_L;
309 34 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
310 34 cheatkeys[Cheat::Kill][0] = KEY_K;
311 34 cheatkeys[Cheat::GoTo][0] = KEY_G;
312 34 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
313 34 cheatkeys[Cheat::ShowL0][0] = KEY_0;
314 34 cheatkeys[Cheat::ShowL1][0] = KEY_1;
315 34 cheatkeys[Cheat::ShowL2][0] = KEY_2;
316 34 cheatkeys[Cheat::ShowL3][0] = KEY_3;
317 34 cheatkeys[Cheat::ShowL4][0] = KEY_4;
318 34 cheatkeys[Cheat::ShowL5][0] = KEY_5;
319 34 cheatkeys[Cheat::ShowL6][0] = KEY_6;
320 34 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
321 34 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
322 34 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
323 34 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
324 34 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
325 34 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
326 34 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
327 34 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
328 34 }
329 34 void load_game_configs()
330 {
331 34 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
332 34 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
333 34 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
334 34 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
335 34 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
336 34 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
337 34 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
338 34 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
339 34 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
340 34 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
341 34 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
342 34 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
343 34 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
344 34 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
345 34 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
346
347 //cheat modifier keya
348 34 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
349 34 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
350 34 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
351 34 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
352
353 //cheat keys
354 34 load_default_cheatkeys();
355 char buf[256];
356
2/2
✓ Branch 0 taken 1190 times.
✓ Branch 1 taken 34 times.
1224 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 1190 times.
✗ Branch 1 not taken.
1190 if(!bindable_cheat((Cheat)q)) continue;
359 1190 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 1190 times.
✗ Branch 1 not taken.
1190 util::lowerstr(cheatname);
361 1190 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1190 times.
✗ Branch 1 not taken.
1190 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
363 1190 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
364
1/2
✓ Branch 0 taken 1190 times.
✗ Branch 1 not taken.
1190 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
365 1190 }
366
367
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
368 joystick_index = 0;
369
370 34 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
371 34 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
372 34 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
373 34 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
374 34 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
375 34 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
376 34 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
377 34 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
378 34 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
379 34 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
380
381 34 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
382 34 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
383 34 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
384 34 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
385
386 34 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
387 34 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
388 34 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
389 34 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
390 34 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
391 34 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
392 34 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
393 34 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
394 34 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
395 34 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
396 34 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
397
398 34 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
399 34 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
400 34 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
401 34 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
402
403 34 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
404
405 34 digi_volume = zc_get_config(sfx_sect,"digi",248);
406 34 midi_volume = zc_get_config(sfx_sect,"midi",255);
407 34 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
408 34 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
409 34 pan_style = zc_get_config(sfx_sect,"pan",1);
410 // 1 <= zcmusic_bufsz <= 128
411 34 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
412 34 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
413 34 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
414 34 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
415 34 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
416 34 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
417 34 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
418 #ifdef __EMSCRIPTEN__
419 if (em_is_mobile()) NameEntryMode = 2;
420 #endif
421 34 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
422 34 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
423 34 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
424 34 title_version = zc_get_config(cfg_sect,"title",2);
425 34 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
426 34 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
427
428 //default - scale x2, 640 x 480
429 34 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
430 34 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
431 34 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
432 34 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
433 34 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
434 34 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
435 34 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
436
437 34 loadlast = zc_get_config(cfg_sect,"load_last",0);
438
439 34 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
440
441 34 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
442
443 34 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
444 34 info_opacity = zc_get_config("zc","debug_info_opacity",255);
445 #ifdef _WIN32
446 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
447 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
448 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
449 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
450
451 // This one's for Aero
452 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
453
454 // And this one fixes patches unloading on some MIDI setups
455 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
456 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
457 #else //UNIX
458 34 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
459 34 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
460 34 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
461 #endif
462 34 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
463 34 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
464
465 34 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
466
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(strlen(qstdir)==0)
468 {
469 34 getcwd(qstdir,2048);
470 34 fix_filename_case(qstdir);
471 34 fix_filename_slashes(qstdir);
472 34 put_backslash(qstdir);
473 34 }
474 else
475 {
476 chop_path(qstdir);
477 }
478
479 34 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
480 34 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
481 34 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
482 34 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
483 34 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
484 34 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
485 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
486 34 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
487 34 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
488 34 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
489 34 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
490 34 }
491
492 void save_control_configs(bool kb)
493 {
494 if(kb)
495 {
496 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
497 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
498 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
499 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
500
501 if (!replay_is_replaying())
502 {
503 zc_set_config(ctrl_sect,"key_a",Akey);
504 zc_set_config(ctrl_sect,"key_b",Bkey);
505 zc_set_config(ctrl_sect,"key_s",Skey);
506 zc_set_config(ctrl_sect,"key_l",Lkey);
507 zc_set_config(ctrl_sect,"key_r",Rkey);
508 zc_set_config(ctrl_sect,"key_p",Pkey);
509 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
510 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
511 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
512 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
513 zc_set_config(ctrl_sect,"key_up", DUkey);
514 zc_set_config(ctrl_sect,"key_down", DDkey);
515 zc_set_config(ctrl_sect,"key_left", DLkey);
516 zc_set_config(ctrl_sect,"key_right",DRkey);
517 }
518 }
519 else
520 {
521 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
522 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
523 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
524 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
525 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
526 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
527 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
528 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
529 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
530 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
531 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
532 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
533 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
534 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
535
536 zc_set_config(ctrl_sect,"btn_a",Abtn);
537 zc_set_config(ctrl_sect,"btn_b",Bbtn);
538 zc_set_config(ctrl_sect,"btn_s",Sbtn);
539 zc_set_config(ctrl_sect,"btn_m",Mbtn);
540 zc_set_config(ctrl_sect,"btn_l",Lbtn);
541 zc_set_config(ctrl_sect,"btn_r",Rbtn);
542 zc_set_config(ctrl_sect,"btn_p",Pbtn);
543 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
544 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
545 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
546 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
547
548 zc_set_config(ctrl_sect,"btn_up",DUbtn);
549 zc_set_config(ctrl_sect,"btn_down",DDbtn);
550 zc_set_config(ctrl_sect,"btn_left",DLbtn);
551 zc_set_config(ctrl_sect,"btn_right",DRbtn);
552 }
553 }
554
555 void save_cheatkeys()
556 {
557 char buf[256];
558 for(size_t q = 1; q < Cheat::Last; ++q)
559 {
560 if(!bindable_cheat((Cheat)q)) continue;
561 std::string cheatname = cheat_to_string((Cheat)q);
562 util::lowerstr(cheatname);
563 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
564 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
565 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
566 if(cheatkeys[q][1])
567 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
568 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
569 }
570 }
571
572 void save_game_configs()
573 {
574 packfile_password("");
575
576 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
577
578 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
579 {
580 int o_window_x, o_window_y;
581 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
582 zc_set_config(cfg_sect,"window_x",o_window_x);
583 zc_set_config(cfg_sect,"window_y",o_window_y);
584 }
585
586 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
587 {
588 double monitor_scale = zc_get_monitor_scale();
589 window_width = al_get_display_width(all_get_display()) / monitor_scale;
590 window_height = al_get_display_height(all_get_display()) / monitor_scale;
591 zc_set_config(cfg_sect,"window_width",window_width);
592 zc_set_config(cfg_sect,"window_height",window_height);
593 }
594
595 zc_set_config(cfg_sect,"load_last",loadlast);
596 chop_path(qstdir);
597 zc_set_config(cfg_sect,qst_dir_name,qstdir);
598 zc_set_config("SAVEFILE","save_filename",save_file_name);
599 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
600
601 flush_config_file();
602 #ifdef __EMSCRIPTEN__
603 em_sync_fs();
604 #endif
605 }
606
607 //----------------------------------------------------------------
608
609 // Timers
610
611 30938 void fps_callback()
612 {
613 30938 lastfps=framecnt;
614 30938 dword tempsecs = fps_secs;
615 30938 ++tempsecs;
616 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
617 30938 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
618 30938 ++fps_secs;
619 30938 framecnt=0;
620 30938 }
621
622 END_OF_FUNCTION(fps_callback)
623
624 34 int32_t Z_init_timers()
625 {
626 static bool didit = false;
627 const static char *err_str = "Couldn't allocate timer";
628 34 err_str = err_str; //Unused variable warning
629
630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(didit)
631 return 1;
632
633 34 didit = true;
634
635 LOCK_VARIABLE(lastfps);
636 LOCK_VARIABLE(framecnt);
637 LOCK_FUNCTION(fps_callback);
638
639
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
640 return 0;
641
642 34 return 1;
643 34 }
644
645 void Z_remove_timers()
646 {
647 remove_int(fps_callback);
648 }
649
650 //----------------------------------------------------------------
651
652 void go()
653 {
654 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
655 }
656
657 void comeback()
658 {
659 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
660 }
661
662 void dump_pal(BITMAP *dest)
663 {
664 for(int32_t i=0; i<256; i++)
665 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
666 }
667
668 //----------------------------------------------------------------
669
670 int game_mouse_index = ZCM_BLANK;
671 static bool system_mouse = false;
672 96 bool sys_mouse()
673 {
674 96 system_mouse = true;
675 96 return MouseSprite::set(ZCM_NORMAL);
676 }
677 460 bool game_mouse()
678 {
679 460 system_mouse = false;
680 460 return MouseSprite::set(game_mouse_index);
681 }
682 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
683 {
684 if(!bmp)
685 return;
686 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
687 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
688 if(bmp->w == scaledw && bmp->h == scaledh)
689 user_scale = false;
690 if(user_scale || sys_recolor)
691 {
692 if(!user_scale) scale = 1;
693 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
694 if(user_scale)
695 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
696 else
697 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
698 if(sys_recolor)
699 recolor_mouse(tmpbmp);
700 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
701 destroy_bitmap(tmpbmp);
702 }
703 else
704 {
705 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
706 }
707 }
708
709 //Handles converting the mouse sprite from the .dat file
710 34 void recolor_mouse(BITMAP* bmp)
711 {
712
2/2
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 34 times.
578 for(int32_t x = 0; x < bmp->w; ++x)
713 {
714
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 544 times.
9248 for(int32_t y = 0; y < bmp->h; ++y)
715 {
716 8704 int32_t color = getpixel(bmp, x, y);
717
5/5
✓ Branch 0 taken 5916 times.
✓ Branch 1 taken 646 times.
✓ Branch 2 taken 748 times.
✓ Branch 3 taken 782 times.
✓ Branch 4 taken 612 times.
8704 switch(color)
718 {
719 case dvc(1):
720 646 color = jwin_pal[jcCURSORMISC];
721 646 break;
722 case dvc(2):
723 748 color = jwin_pal[jcCURSOROUTLINE];
724 748 break;
725 case dvc(3):
726 782 color = jwin_pal[jcCURSORLIGHT];
727 782 break;
728 case dvc(5):
729 612 color = jwin_pal[jcCURSORDARK];
730 612 break;
731 default:
732 5916 continue;
733 }
734 2788 putpixel(bmp, x, y, color);
735 2788 }
736 544 }
737 34 }
738 34 void load_mouse()
739 {
740 34 enter_sys_pal();
741 34 MouseSprite::set(-1);
742 34 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
743 34 int32_t sz = 16*scale;
744
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 34 times.
68 for(int32_t j = 0; j < 1; ++j)
745 {
746 34 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
747
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(zcmouse[j])
748 destroy_bitmap(zcmouse[j]);
749 34 zcmouse[j] = create_bitmap_ex(8,sz,sz);
750 34 clear_bitmap(zcmouse[j]);
751 34 clear_bitmap(tmpbmp);
752 34 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
753 34 recolor_mouse(tmpbmp);
754
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(sz!=16)
755 34 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
756 else
757 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
758 34 destroy_bitmap(tmpbmp);
759 34 }
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(!hw_palette) hw_palette = &RAMpal;
761 34 zc_set_palette(*hw_palette);
762
763 34 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
764 34 clear_bitmap(blankmouse);
765
766 34 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
767 34 MouseSprite::assign(ZCM_BLANK, blankmouse);
768 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
769
770 //Reload the mouse
771
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(system_mouse)
772 34 sys_mouse();
773 else game_mouse();
774
775 34 destroy_bitmap(blankmouse);
776 34 exit_sys_pal();
777 34 }
778
779 // sets the video mode and initializes the palette and mouse sprite
780 34 bool game_vid_mode(int32_t mode,int32_t wait)
781 {
782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
783 {
784 return false;
785 }
786
787 34 scrx = (resx-320)>>1;
788 34 scry = (resy-240)>>1;
789
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 34 times.
68 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
790 34 zcmouse[q] = NULL;
791 34 load_mouse();
792
793
2/2
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 34 times.
578 for(int32_t i=240; i<256; i++)
794 544 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
795
796 34 zc_set_palette(RAMpal);
797 34 clear_to_color(screen,BLACK);
798
799 34 rest(wait);
800 34 return true;
801 34 }
802
803 8 void null_quest()
804 {
805 char qstdat_string[2048];
806 8 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
807 8 strcat(qstdat_string,"#NESQST_NEW_QST");
808
809 #ifdef __EMSCRIPTEN__
810 // The quest template data file is not included because it's really big and isn't really needed
811 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
812 // which is much smaller.
813 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
814 #endif
815
816 8 byte skip_flags[4] = { 0 };
817
818 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,skip_flags,0,false);
819 8 }
820
821 // TODO remove
822 8 void init_NES_mode()
823 {
824 8 null_quest();
825 8 }
826
827 //----------------------------------------------------------------
828
829 qword trianglelines[16]=
830 {
831 0x0000000000000000ULL,
832 0xFD00000000000000ULL,
833 0xFDFD000000000000ULL,
834 0xFDFDFD0000000000ULL,
835 0xFDFDFDFD00000000ULL,
836 0xFDFDFDFDFD000000ULL,
837 0xFDFDFDFDFDFD0000ULL,
838 0xFDFDFDFDFDFDFD00ULL,
839 0xFDFDFDFDFDFDFDFDULL,
840 0x00FDFDFDFDFDFDFDULL,
841 0x0000FDFDFDFDFDFDULL,
842 0x000000FDFDFDFDFDULL,
843 0x00000000FDFDFDFDULL,
844 0x0000000000FDFDFDULL,
845 0x000000000000FDFDULL,
846 0x00000000000000FDULL,
847 };
848
849 word screen_triangles[28][32];
850 /*
851 qword triangles[4][16]= //[direction][value]
852 {
853 {
854 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
855 },
856 {
857 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
858 },
859 {
860 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
861 },
862 {
863 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
864 }
865 };
866 */
867
868
869 /*
870 byte triangles[4][16][8]= //[direction][value][line]
871 {
872 {
873 {
874 0, 0, 0, 0, 0, 0, 0, 0
875 },
876 {
877 1, 0, 0, 0, 0, 0, 0, 0
878 },
879 {
880 2, 1, 0, 0, 0, 0, 0, 0
881 },
882 {
883 3, 2, 1, 0, 0, 0, 0, 0
884 },
885 {
886 4, 3, 2, 1, 0, 0, 0, 0
887 },
888 {
889 5, 4, 3, 2, 1, 0, 0, 0
890 },
891 {
892 6, 5, 4, 3, 2, 1, 0, 0
893 },
894 {
895 7, 6, 5, 4, 3, 2, 1, 0
896 },
897 {
898 8, 7, 6, 5, 4, 3, 2, 1
899 },
900 {
901 8, 8, 7, 6, 5, 4, 3, 2
902 },
903 {
904 8, 8, 8, 7, 6, 5, 4, 3
905 },
906 {
907 8, 8, 8, 8, 7, 6, 5, 4
908 },
909 {
910 8, 8, 8, 8, 8, 7, 6, 5
911 },
912 {
913 8, 8, 8, 8, 8, 8, 7, 6
914 },
915 {
916 8, 8, 8, 8, 8, 8, 8, 7
917 },
918 {
919 8, 8, 8, 8, 8, 8, 8, 8
920 }
921 },
922 {
923 {
924 0, 0, 0, 0, 0, 0, 0, 0
925 },
926 {
927 15, 0, 0, 0, 0, 0, 0, 0
928 },
929 {
930 14, 15, 0, 0, 0, 0, 0, 0
931 },
932 {
933 13, 14, 15, 0, 0, 0, 0, 0
934 },
935 {
936 12, 13, 14, 15, 0, 0, 0, 0
937 },
938 {
939 11, 12, 13, 14, 15, 0, 0, 0
940 },
941 {
942 10, 11, 12, 13, 14, 15, 0, 0
943 },
944 {
945 9, 10, 11, 12, 13, 14, 15, 0
946 },
947 {
948 8, 9, 10, 11, 12, 13, 14, 15
949 },
950 {
951 8, 8, 9, 10, 11, 12, 13, 14
952 },
953 {
954 8, 8, 8, 9, 10, 11, 12, 13
955 },
956 {
957 8, 8, 8, 8, 9, 10, 11, 12
958 },
959 {
960 8, 8, 8, 8, 8, 9, 10, 11
961 },
962 {
963 8, 8, 8, 8, 8, 8, 9, 10
964 },
965 {
966 8, 8, 8, 8, 8, 8, 8, 9
967 },
968 {
969 8, 8, 8, 8, 8, 8, 8, 8
970 }
971 },
972 {
973 {
974 0, 0, 0, 0, 0, 0, 0, 0
975 },
976 {
977 0, 0, 0, 0, 0, 0, 0, 1
978 },
979 {
980 0, 0, 0, 0, 0, 0, 1, 2
981 },
982 {
983 0, 0, 0, 0, 0, 1, 2, 3
984 },
985 {
986 0, 0, 0, 0, 1, 2, 3, 4
987 },
988 {
989 0, 0, 0, 1, 2, 3, 4, 5
990 },
991 {
992 0, 0, 1, 2, 3, 4, 5, 6
993 },
994 {
995 0, 1, 2, 3, 4, 5, 6, 7
996 },
997 {
998 1, 2, 3, 4, 5, 6, 7, 8
999 },
1000 {
1001 2, 3, 4, 5, 6, 7, 8, 8
1002 },
1003 {
1004 3, 4, 5, 6, 7, 8, 8, 8
1005 },
1006 {
1007 4, 5, 6, 7, 8, 8, 8, 8
1008 },
1009 {
1010 5, 6, 7, 8, 8, 8, 8, 8
1011 },
1012 {
1013 6, 7, 8, 8, 8, 8, 8, 8
1014 },
1015 {
1016 7, 8, 8, 8, 8, 8, 8, 8
1017 },
1018 {
1019 8, 8, 8, 8, 8, 8, 8, 8
1020 }
1021 },
1022 {
1023 {
1024 0, 0, 0, 0, 0, 0, 0, 0
1025 },
1026 {
1027 0, 0, 0, 0, 0, 0, 0, 15
1028 },
1029 {
1030 0, 0, 0, 0, 0, 0, 15, 14
1031 },
1032 {
1033 0, 0, 0, 0, 0, 15, 14, 13
1034 },
1035 {
1036 0, 0, 0, 0, 15, 14, 13, 12
1037 },
1038 {
1039 0, 0, 0, 15, 14, 13, 12, 11
1040 },
1041 {
1042 0, 0, 15, 14, 13, 12, 11, 10
1043 },
1044 {
1045 0, 15, 14, 13, 12, 11, 10, 9
1046 },
1047 {
1048 15, 14, 13, 12, 11, 10, 9, 8
1049 },
1050 {
1051 14, 13, 12, 11, 10, 9, 8, 8
1052 },
1053 {
1054 13, 12, 11, 10, 9, 8, 8, 8
1055 },
1056 {
1057 12, 11, 10, 9, 8, 8, 8, 8
1058 },
1059 {
1060 11, 10, 9, 8, 8, 8, 8, 8
1061 },
1062 {
1063 10, 9, 8, 8, 8, 8, 8, 8
1064 },
1065 {
1066 9, 8, 8, 8, 8, 8, 8, 8
1067 },
1068 {
1069 8, 8, 8, 8, 8, 8, 8, 8
1070 }
1071 }
1072 };
1073 */
1074
1075
1076
1077 /*
1078 for (int32_t blockrow=0; blockrow<30; ++i)
1079 {
1080 for (int32_t linerow=0; linerow<8; ++i)
1081 {
1082 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1083 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1084 {
1085 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1086 ++triangleline;
1087 }
1088 }
1089 }
1090 */
1091
1092 // the ULL suffixes are to prevent this warning:
1093 // warning: integer constant is too large for "int32_t" type
1094
1095 qword triangles[4][16][8]= //[direction][value][line]
1096 {
1097 {
1098 {
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL,
1106 0x0000000000000000ULL
1107 },
1108 {
1109 0xFD00000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL,
1116 0x0000000000000000ULL
1117 },
1118 {
1119 0xFDFD000000000000ULL,
1120 0xFD00000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL
1127 },
1128 {
1129 0xFDFDFD0000000000ULL,
1130 0xFDFD000000000000ULL,
1131 0xFD00000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL
1137 },
1138 {
1139 0xFDFDFDFD00000000ULL,
1140 0xFDFDFD0000000000ULL,
1141 0xFDFD000000000000ULL,
1142 0xFD00000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL,
1146 0x0000000000000000ULL
1147 },
1148 {
1149 0xFDFDFDFDFD000000ULL,
1150 0xFDFDFDFD00000000ULL,
1151 0xFDFDFD0000000000ULL,
1152 0xFDFD000000000000ULL,
1153 0xFD00000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL
1157 },
1158 {
1159 0xFDFDFDFDFDFD0000ULL,
1160 0xFDFDFDFDFD000000ULL,
1161 0xFDFDFDFD00000000ULL,
1162 0xFDFDFD0000000000ULL,
1163 0xFDFD000000000000ULL,
1164 0xFD00000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL
1167 },
1168 {
1169 0xFDFDFDFDFDFDFD00ULL,
1170 0xFDFDFDFDFDFD0000ULL,
1171 0xFDFDFDFDFD000000ULL,
1172 0xFDFDFDFD00000000ULL,
1173 0xFDFDFD0000000000ULL,
1174 0xFDFD000000000000ULL,
1175 0xFD00000000000000ULL,
1176 0x0000000000000000ULL
1177 },
1178 {
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFD00ULL,
1181 0xFDFDFDFDFDFD0000ULL,
1182 0xFDFDFDFDFD000000ULL,
1183 0xFDFDFDFD00000000ULL,
1184 0xFDFDFD0000000000ULL,
1185 0xFDFD000000000000ULL,
1186 0xFD00000000000000ULL
1187 },
1188 {
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFD00ULL,
1192 0xFDFDFDFDFDFD0000ULL,
1193 0xFDFDFDFDFD000000ULL,
1194 0xFDFDFDFD00000000ULL,
1195 0xFDFDFD0000000000ULL,
1196 0xFDFD000000000000ULL
1197 },
1198 {
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFD00ULL,
1203 0xFDFDFDFDFDFD0000ULL,
1204 0xFDFDFDFDFD000000ULL,
1205 0xFDFDFDFD00000000ULL,
1206 0xFDFDFD0000000000ULL
1207 },
1208 {
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFD00ULL,
1214 0xFDFDFDFDFDFD0000ULL,
1215 0xFDFDFDFDFD000000ULL,
1216 0xFDFDFDFD00000000ULL
1217 },
1218 {
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFD00ULL,
1225 0xFDFDFDFDFDFD0000ULL,
1226 0xFDFDFDFDFD000000ULL
1227 },
1228 {
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFDFDULL,
1235 0xFDFDFDFDFDFDFD00ULL,
1236 0xFDFDFDFDFDFD0000ULL
1237 },
1238 {
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFDFDULL,
1246 0xFDFDFDFDFDFDFD00ULL
1247 },
1248 {
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL,
1256 0xFDFDFDFDFDFDFDFDULL
1257 }
1258 },
1259 {
1260 {
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL,
1268 0x0000000000000000ULL
1269 },
1270 {
1271 0x00000000000000FDULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL,
1278 0x0000000000000000ULL
1279 },
1280 {
1281 0x000000000000FDFDULL,
1282 0x00000000000000FDULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL
1289 },
1290 {
1291 0x0000000000FDFDFDULL,
1292 0x000000000000FDFDULL,
1293 0x00000000000000FDULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL
1299 },
1300 {
1301 0x00000000FDFDFDFDULL,
1302 0x0000000000FDFDFDULL,
1303 0x000000000000FDFDULL,
1304 0x00000000000000FDULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL,
1308 0x0000000000000000ULL
1309 },
1310 {
1311 0x000000FDFDFDFDFDULL,
1312 0x00000000FDFDFDFDULL,
1313 0x0000000000FDFDFDULL,
1314 0x000000000000FDFDULL,
1315 0x00000000000000FDULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL
1319 },
1320 {
1321 0x0000FDFDFDFDFDFDULL,
1322 0x000000FDFDFDFDFDULL,
1323 0x00000000FDFDFDFDULL,
1324 0x0000000000FDFDFDULL,
1325 0x000000000000FDFDULL,
1326 0x00000000000000FDULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL
1329 },
1330 {
1331 0x00FDFDFDFDFDFDFDULL,
1332 0x0000FDFDFDFDFDFDULL,
1333 0x000000FDFDFDFDFDULL,
1334 0x00000000FDFDFDFDULL,
1335 0x0000000000FDFDFDULL,
1336 0x000000000000FDFDULL,
1337 0x00000000000000FDULL,
1338 0x0000000000000000ULL
1339 },
1340 {
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0x00FDFDFDFDFDFDFDULL,
1343 0x0000FDFDFDFDFDFDULL,
1344 0x000000FDFDFDFDFDULL,
1345 0x00000000FDFDFDFDULL,
1346 0x0000000000FDFDFDULL,
1347 0x000000000000FDFDULL,
1348 0x00000000000000FDULL
1349 },
1350 {
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0x00FDFDFDFDFDFDFDULL,
1354 0x0000FDFDFDFDFDFDULL,
1355 0x000000FDFDFDFDFDULL,
1356 0x00000000FDFDFDFDULL,
1357 0x0000000000FDFDFDULL,
1358 0x000000000000FDFDULL
1359 },
1360 {
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0x00FDFDFDFDFDFDFDULL,
1365 0x0000FDFDFDFDFDFDULL,
1366 0x000000FDFDFDFDFDULL,
1367 0x00000000FDFDFDFDULL,
1368 0x0000000000FDFDFDULL
1369 },
1370 {
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0x00FDFDFDFDFDFDFDULL,
1376 0x0000FDFDFDFDFDFDULL,
1377 0x000000FDFDFDFDFDULL,
1378 0x00000000FDFDFDFDULL
1379 },
1380 {
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0x00FDFDFDFDFDFDFDULL,
1387 0x0000FDFDFDFDFDFDULL,
1388 0x000000FDFDFDFDFDULL
1389 },
1390 {
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0xFDFDFDFDFDFDFDFDULL,
1397 0x00FDFDFDFDFDFDFDULL,
1398 0x0000FDFDFDFDFDFDULL
1399 },
1400 {
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0xFDFDFDFDFDFDFDFDULL,
1408 0x00FDFDFDFDFDFDFDULL
1409 },
1410 {
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL,
1418 0xFDFDFDFDFDFDFDFDULL
1419 }
1420 },
1421 {
1422 {
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0x0000000000000000ULL,
1430 0x0000000000000000ULL
1431 },
1432 {
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0x0000000000000000ULL,
1439 0x0000000000000000ULL,
1440 0xFD00000000000000ULL
1441 },
1442 {
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0x0000000000000000ULL,
1448 0x0000000000000000ULL,
1449 0xFD00000000000000ULL,
1450 0xFDFD000000000000ULL
1451 },
1452 {
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0x0000000000000000ULL,
1458 0xFD00000000000000ULL,
1459 0xFDFD000000000000ULL,
1460 0xFDFDFD0000000000ULL
1461 },
1462 {
1463 0x0000000000000000ULL,
1464 0x0000000000000000ULL,
1465 0x0000000000000000ULL,
1466 0x0000000000000000ULL,
1467 0xFD00000000000000ULL,
1468 0xFDFD000000000000ULL,
1469 0xFDFDFD0000000000ULL,
1470 0xFDFDFDFD00000000ULL
1471 },
1472 {
1473 0x0000000000000000ULL,
1474 0x0000000000000000ULL,
1475 0x0000000000000000ULL,
1476 0xFD00000000000000ULL,
1477 0xFDFD000000000000ULL,
1478 0xFDFDFD0000000000ULL,
1479 0xFDFDFDFD00000000ULL,
1480 0xFDFDFDFDFD000000ULL
1481 },
1482 {
1483 0x0000000000000000ULL,
1484 0x0000000000000000ULL,
1485 0xFD00000000000000ULL,
1486 0xFDFD000000000000ULL,
1487 0xFDFDFD0000000000ULL,
1488 0xFDFDFDFD00000000ULL,
1489 0xFDFDFDFDFD000000ULL,
1490 0xFDFDFDFDFDFD0000ULL
1491 },
1492 {
1493 0x0000000000000000ULL,
1494 0xFD00000000000000ULL,
1495 0xFDFD000000000000ULL,
1496 0xFDFDFD0000000000ULL,
1497 0xFDFDFDFD00000000ULL,
1498 0xFDFDFDFDFD000000ULL,
1499 0xFDFDFDFDFDFD0000ULL,
1500 0xFDFDFDFDFDFDFD00ULL
1501 },
1502 {
1503 0xFD00000000000000ULL,
1504 0xFDFD000000000000ULL,
1505 0xFDFDFD0000000000ULL,
1506 0xFDFDFDFD00000000ULL,
1507 0xFDFDFDFDFD000000ULL,
1508 0xFDFDFDFDFDFD0000ULL,
1509 0xFDFDFDFDFDFDFD00ULL,
1510 0xFDFDFDFDFDFDFDFDULL
1511 },
1512 {
1513 0xFDFD000000000000ULL,
1514 0xFDFDFD0000000000ULL,
1515 0xFDFDFDFD00000000ULL,
1516 0xFDFDFDFDFD000000ULL,
1517 0xFDFDFDFDFDFD0000ULL,
1518 0xFDFDFDFDFDFDFD00ULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL
1521 },
1522 {
1523 0xFDFDFD0000000000ULL,
1524 0xFDFDFDFD00000000ULL,
1525 0xFDFDFDFDFD000000ULL,
1526 0xFDFDFDFDFDFD0000ULL,
1527 0xFDFDFDFDFDFDFD00ULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL,
1530 0xFDFDFDFDFDFDFDFDULL
1531 },
1532 {
1533 0xFDFDFDFD00000000ULL,
1534 0xFDFDFDFDFD000000ULL,
1535 0xFDFDFDFDFDFD0000ULL,
1536 0xFDFDFDFDFDFDFD00ULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL
1541 },
1542 {
1543 0xFDFDFDFDFD000000ULL,
1544 0xFDFDFDFDFDFD0000ULL,
1545 0xFDFDFDFDFDFDFD00ULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL,
1550 0xFDFDFDFDFDFDFDFDULL
1551 },
1552 {
1553 0xFDFDFDFDFDFD0000ULL,
1554 0xFDFDFDFDFDFDFD00ULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL,
1559 0xFDFDFDFDFDFDFDFDULL,
1560 0xFDFDFDFDFDFDFDFDULL
1561 },
1562 {
1563 0xFDFDFDFDFDFDFD00ULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL,
1570 0xFDFDFDFDFDFDFDFDULL
1571 },
1572 {
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL,
1579 0xFDFDFDFDFDFDFDFDULL,
1580 0xFDFDFDFDFDFDFDFDULL
1581 }
1582 },
1583 {
1584 {
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x0000000000000000ULL,
1592 0x0000000000000000ULL
1593 },
1594 {
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x0000000000000000ULL,
1601 0x0000000000000000ULL,
1602 0x00000000000000FDULL
1603 },
1604 {
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x0000000000000000ULL,
1610 0x0000000000000000ULL,
1611 0x00000000000000FDULL,
1612 0x000000000000FDFDULL
1613 },
1614 {
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x0000000000000000ULL,
1620 0x00000000000000FDULL,
1621 0x000000000000FDFDULL,
1622 0x0000000000FDFDFDULL
1623 },
1624 {
1625 0x0000000000000000ULL,
1626 0x0000000000000000ULL,
1627 0x0000000000000000ULL,
1628 0x0000000000000000ULL,
1629 0x00000000000000FDULL,
1630 0x000000000000FDFDULL,
1631 0x0000000000FDFDFDULL,
1632 0x00000000FDFDFDFDULL
1633 },
1634 {
1635 0x0000000000000000ULL,
1636 0x0000000000000000ULL,
1637 0x0000000000000000ULL,
1638 0x00000000000000FDULL,
1639 0x000000000000FDFDULL,
1640 0x0000000000FDFDFDULL,
1641 0x00000000FDFDFDFDULL,
1642 0x000000FDFDFDFDFDULL
1643 },
1644 {
1645 0x0000000000000000ULL,
1646 0x0000000000000000ULL,
1647 0x00000000000000FDULL,
1648 0x000000000000FDFDULL,
1649 0x0000000000FDFDFDULL,
1650 0x00000000FDFDFDFDULL,
1651 0x000000FDFDFDFDFDULL,
1652 0x0000FDFDFDFDFDFDULL
1653 },
1654 {
1655 0x0000000000000000ULL,
1656 0x00000000000000FDULL,
1657 0x000000000000FDFDULL,
1658 0x0000000000FDFDFDULL,
1659 0x00000000FDFDFDFDULL,
1660 0x000000FDFDFDFDFDULL,
1661 0x0000FDFDFDFDFDFDULL,
1662 0x00FDFDFDFDFDFDFDULL
1663 },
1664 {
1665 0x00000000000000FDULL,
1666 0x000000000000FDFDULL,
1667 0x0000000000FDFDFDULL,
1668 0x00000000FDFDFDFDULL,
1669 0x000000FDFDFDFDFDULL,
1670 0x0000FDFDFDFDFDFDULL,
1671 0x00FDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL
1673 },
1674 {
1675 0x000000000000FDFDULL,
1676 0x0000000000FDFDFDULL,
1677 0x00000000FDFDFDFDULL,
1678 0x000000FDFDFDFDFDULL,
1679 0x0000FDFDFDFDFDFDULL,
1680 0x00FDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL
1683 },
1684 {
1685 0x0000000000FDFDFDULL,
1686 0x00000000FDFDFDFDULL,
1687 0x000000FDFDFDFDFDULL,
1688 0x0000FDFDFDFDFDFDULL,
1689 0x00FDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL
1693 },
1694 {
1695 0x00000000FDFDFDFDULL,
1696 0x000000FDFDFDFDFDULL,
1697 0x0000FDFDFDFDFDFDULL,
1698 0x00FDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL
1703 },
1704 {
1705 0x000000FDFDFDFDFDULL,
1706 0x0000FDFDFDFDFDFDULL,
1707 0x00FDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL
1713 },
1714 {
1715 0x0000FDFDFDFDFDFDULL,
1716 0x00FDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL,
1721 0xFDFDFDFDFDFDFDFDULL,
1722 0xFDFDFDFDFDFDFDFDULL
1723 },
1724 {
1725 0x00FDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL,
1732 0xFDFDFDFDFDFDFDFDULL
1733 },
1734 {
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL,
1741 0xFDFDFDFDFDFDFDFDULL,
1742 0xFDFDFDFDFDFDFDFDULL
1743 }
1744 }
1745 };
1746
1747 int32_t black_opening_count=0;
1748 int32_t black_opening_x,black_opening_y;
1749 int32_t black_opening_shape;
1750
1751 1134 int32_t choose_opening_shape()
1752 {
1753 // First, count how many bits are set
1754 1134 int32_t numBits=0;
1755 int32_t bitCounter;
1756
1757
2/2
✓ Branch 0 taken 5670 times.
✓ Branch 1 taken 1134 times.
6804 for(int32_t i=0; i<bosMAX; i++)
1758 {
1759
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 1350 times.
5670 if(COOLSCROLL&(1<<i))
1760 1350 numBits++;
1761 5670 }
1762
1763 // Shouldn't happen...
1764
1/2
✓ Branch 0 taken 1134 times.
✗ Branch 1 not taken.
1134 if(numBits==0)
1765 return bosCIRCLE;
1766
1767 // Pick a bit
1768 1134 bitCounter=zc_rand()%numBits+1;
1769
1770
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 26 times.
1426 for(int32_t i=0; i<bosMAX; i++)
1771 {
1772 // If this bit is set, decrement the bit counter
1773
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1264 times.
1400 if(COOLSCROLL&(1<<i))
1774 1264 bitCounter--;
1775
1776 // When the counter hits 0, return a value based on
1777 // which bit it stopped on.
1778 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1779
2/2
✓ Branch 0 taken 1108 times.
✓ Branch 1 taken 292 times.
1400 if(bitCounter==0)
1780 1108 return i;
1781 292 }
1782
1783 // Shouldn't be necessary, but the compiler might complain, at least
1784 26 return bosCIRCLE;
1785 1134 }
1786
1787 312 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1788 {
1789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312 times.
312 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1790
1791 312 int32_t w=256, h=224;
1792 312 int32_t blockrows=28, blockcolumns=32;
1793 312 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1794
1795
2/2
✓ Branch 0 taken 8736 times.
✓ Branch 1 taken 312 times.
9048 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1796 {
1797
2/2
✓ Branch 0 taken 279552 times.
✓ Branch 1 taken 8736 times.
288288 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1798 {
1799
2/2
✓ Branch 0 taken 148819 times.
✓ Branch 1 taken 130733 times.
279552 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1800 279552 }
1801 8736 }
1802
1803 312 black_opening_count = 66;
1804 312 black_opening_x = x;
1805 312 black_opening_y = y;
1806 312 lensclk = 0;
1807 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1808
1809
1810
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(black_opening_shape == bosFADEBLACK)
1811 {
1812 refreshTints();
1813 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1814 }
1815
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(wait)
1816 {
1817 FFCore.warpScriptCheck();
1818 for(int32_t i=0; i<66; i++)
1819 {
1820 draw_screen(tmpscr);
1821 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1822 advanceframe(true);
1823
1824 if(Quit)
1825 {
1826 break;
1827 }
1828 }
1829 }
1830 312 }
1831
1832 822 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1833 {
1834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 822 times.
822 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1835
1836 822 int32_t w=256, h=224;
1837 822 int32_t blockrows=28, blockcolumns=32;
1838 822 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1839
1840
2/2
✓ Branch 0 taken 23016 times.
✓ Branch 1 taken 822 times.
23838 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1841 {
1842
2/2
✓ Branch 0 taken 736512 times.
✓ Branch 1 taken 23016 times.
759528 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1843 {
1844
2/2
✓ Branch 0 taken 335267 times.
✓ Branch 1 taken 401245 times.
736512 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1845 736512 }
1846 23016 }
1847
1848 822 black_opening_count = -66;
1849 822 black_opening_x = x;
1850 822 black_opening_y = y;
1851 822 lensclk = 0;
1852
1/2
✓ Branch 0 taken 822 times.
✗ Branch 1 not taken.
822 if(black_opening_shape == bosFADEBLACK)
1853 {
1854 refreshTints();
1855 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1856 }
1857
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 627 times.
822 if(wait)
1858 {
1859 627 FFCore.warpScriptCheck();
1860
2/2
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 41382 times.
42009 for(int32_t i=0; i<66; i++)
1861 {
1862 41382 draw_screen(tmpscr);
1863 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1864 41382 advanceframe(true);
1865
1866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41382 times.
41382 if(Quit)
1867 {
1868 break;
1869 }
1870 41382 }
1871 627 }
1872 822 }
1873
1874 74844 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1875 {
1876 74844 clear_to_color(tmp_scr,BLACK);
1877 74844 int32_t w=256, h=224;
1878
1879
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 2838 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70488 times.
74844 switch(black_opening_shape)
1880 {
1881 case bosOVAL:
1882 {
1883 858 double new_w=(w/2)+abs(w/2-x);
1884 858 double new_h=(h/2)+abs(h/2-y);
1885 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1886 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1887 858 break;
1888 }
1889
1890 case bosTRIANGLE:
1891 {
1892 660 double new_w=(w/2)+abs(w/2-x);
1893 660 double new_h=(h/2)+abs(h/2-y);
1894 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1895 660 double P2= (PI/2);
1896 660 double P23=(2*PI/3);
1897 660 double P43=(4*PI/3);
1898 660 double Pa= (-4*PI*a/(3*max_a));
1899 660 double angle=P2+Pa;
1900 660 double a0=angle;
1901 660 double a2=angle+P23;
1902 660 double a4=angle+P43;
1903 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1904 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1905 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1906 0);
1907 660 break;
1908 }
1909
1910 case bosSMAS:
1911 {
1912
2/2
✓ Branch 0 taken 1452 times.
✓ Branch 1 taken 1386 times.
2838 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1913
1914
2/2
✓ Branch 0 taken 79464 times.
✓ Branch 1 taken 2838 times.
82302 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1915 {
1916
2/2
✓ Branch 0 taken 635712 times.
✓ Branch 1 taken 79464 times.
715176 for(int32_t linerow=0; linerow<8; ++linerow)
1917 {
1918 635712 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1919
1920
2/2
✓ Branch 0 taken 20342784 times.
✓ Branch 1 taken 635712 times.
20978496 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1921 {
1922 61028352 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1923
6/6
✓ Branch 0 taken 14117840 times.
✓ Branch 1 taken 6224944 times.
✓ Branch 2 taken 13330568 times.
✓ Branch 3 taken 7012216 times.
✓ Branch 4 taken 7105624 times.
✓ Branch 5 taken 6224944 times.
20342784 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1924 20342784 [linerow];
1925 20342784 ++triangleline;
1926
1927
2/2
✓ Branch 0 taken 17799936 times.
✓ Branch 1 taken 2542848 times.
20342784 if(linerow==0)
1928 {
1929 2542848 }
1930 20342784 }
1931 635712 }
1932 79464 }
1933
1934 2838 break;
1935 }
1936
1937 case bosFADEBLACK:
1938 {
1939 if(black_opening_count<0)
1940 {
1941 black_fade(zc_min(-black_opening_count,63));
1942 }
1943 else if(black_opening_count>0)
1944 {
1945 black_fade(63-zc_max(black_opening_count-3,0));
1946 }
1947 else black_fade(0);
1948 return; //no blitting from tmp_scr!
1949 }
1950
1951 70488 case bosCIRCLE:
1952 default:
1953 {
1954 70488 double new_w=(w/2)+abs(w/2-x);
1955 70488 double new_h=(h/2)+abs(h/2-y);
1956 70488 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1957 //circlefill(tmp_scr,x,y,a<<3,0);
1958 70488 circlefill(tmp_scr,x,y,r,0);
1959 70488 break;
1960 }
1961 }
1962
1963 74844 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1964 74844 }
1965
1966
1967 void black_fade(int32_t fadeamnt)
1968 {
1969 for(int32_t i=0; i < 0xEF; i++)
1970 {
1971 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1972 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1973 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1974 }
1975
1976 refreshpal = true;
1977 }
1978
1979 //----------------------------------------------------------------
1980
1981 32882359 bool item_disabled(int32_t item) //is this item disabled?
1982 {
1983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32882359 times.
32882359 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1984 }
1985
1986 6714641 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1987 {
1988
2/2
✓ Branch 0 taken 80417 times.
✓ Branch 1 taken 6634224 times.
6714641 if(current_item(item_type, true) >=item)
1989 {
1990 80417 return true;
1991 }
1992
1993 6634224 return false;
1994 6714641 }
1995
1996 27681832 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1997 {
1998
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5075336 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3051917 times.
✓ Branch 6 taken 14716598 times.
✓ Branch 7 taken 4803303 times.
✓ Branch 8 taken 34678 times.
27681832 switch(item_type)
1999 {
2000 case itype_bomb:
2001 case itype_sbomb:
2002 {
2003 int32_t itemid = getItemID(itemsbuf, item_type, it);
2004
2005 if(itemid == -1)
2006 return false;
2007
2008 return (game->get_item(itemid));
2009 }
2010
2011 case itype_clock:
2012 {
2013 5075336 int32_t itemid = getItemID(itemsbuf, item_type, it);
2014
2015
2/4
✓ Branch 0 taken 5075336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5075336 times.
✗ Branch 3 not taken.
5075336 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2016 return (game->get_item(itemid));
2017 5075336 return Hero.getClock()?1:0;
2018 }
2019
2020 case itype_key:
2021 return (game->get_keys()>0);
2022
2023 case itype_magiccontainer:
2024 return (game->get_maxmagic()>=game->get_mp_per_block());
2025
2026 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2027 {
2028
1/3
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3051917 switch(it)
2029 {
2030 case -2:
2031 {
2032 for(int32_t i=0; i<MAXLEVELS; i++)
2033 {
2034 if(game->lvlitems[i]&liTRIFORCE)
2035 {
2036 return true;
2037 }
2038 }
2039
2040 return false;
2041 }
2042
2043 case -1:
2044 return (game->lvlitems[dlevel]&liTRIFORCE);
2045
2046 default:
2047
2/4
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3051917 times.
3051917 if(it>=0&&it<MAXLEVELS)
2048 {
2049 3051917 return (game->lvlitems[it]&liTRIFORCE);
2050 }
2051
2052 break;
2053 }
2054
2055 return 0;
2056 }
2057
2058 case itype_map: //it: -2=any, -1=current level, other=that level
2059 {
2060
1/3
✓ Branch 0 taken 14716598 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
14716598 switch(it)
2061 {
2062 case -2:
2063 {
2064 for(int32_t i=0; i<MAXLEVELS; i++)
2065 {
2066 if(game->lvlitems[i]&liMAP)
2067 {
2068 return true;
2069 }
2070 }
2071
2072 return false;
2073 }
2074
2075 case -1:
2076 return (game->lvlitems[dlevel]&liMAP)!=0;
2077
2078 default:
2079
2/4
✓ Branch 0 taken 14716598 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14716598 times.
14716598 if(it>=0&&it<MAXLEVELS)
2080 {
2081 14716598 return (game->lvlitems[it]&liMAP)!=0;
2082 }
2083
2084 break;
2085 }
2086
2087 return 0;
2088 }
2089
2090 case itype_compass: //it: -2=any, -1=current level, other=that level
2091 {
2092
1/3
✓ Branch 0 taken 4803303 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4803303 switch(it)
2093 {
2094 case -2:
2095 {
2096 for(int32_t i=0; i<MAXLEVELS; i++)
2097 {
2098 if(game->lvlitems[i]&liCOMPASS)
2099 {
2100 return true;
2101 }
2102 }
2103
2104 return false;
2105 }
2106
2107 case -1:
2108 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2109
2110 default:
2111
2/4
✓ Branch 0 taken 4803303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4803303 times.
✗ Branch 3 not taken.
4803303 if(it>=0&&it<MAXLEVELS)
2112 {
2113 4803303 return (game->lvlitems[it]&liCOMPASS)!=0;
2114 }
2115
2116 break;
2117 }
2118 return 0;
2119 }
2120
2121 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2122 {
2123
1/3
✓ Branch 0 taken 34678 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
34678 switch(it)
2124 {
2125 case -2:
2126 {
2127 for(int32_t i=0; i<MAXLEVELS; i++)
2128 {
2129 if(game->lvlitems[i]&liBOSSKEY)
2130 {
2131 return true;
2132 }
2133 }
2134
2135 return false;
2136 }
2137
2138 case -1:
2139 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2140
2141 default:
2142
2/4
✓ Branch 0 taken 34678 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34678 times.
34678 if(it>=0&&it<MAXLEVELS)
2143 {
2144 34678 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2145 }
2146 break;
2147 }
2148 return 0;
2149 }
2150
2151 default:
2152 //it=(1<<(it-1));
2153 /*if (item_type>=itype_max)
2154 {
2155 enter_sys_pal();
2156 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2157 exit_sys_pal();
2158
2159 return false;
2160 }*/
2161 int32_t itemid = getItemID(itemsbuf, item_type, it);
2162
2163 if(itemid == -1)
2164 return false;
2165
2166 return game->get_item(itemid);
2167 }
2168 27681832 }
2169
2170
2171 86612879 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2172 {
2173
9/9
✓ Branch 0 taken 5075336 times.
✓ Branch 1 taken 46010191 times.
✓ Branch 2 taken 5075336 times.
✓ Branch 3 taken 5075336 times.
✓ Branch 4 taken 5075336 times.
✓ Branch 5 taken 5075336 times.
✓ Branch 6 taken 5075336 times.
✓ Branch 7 taken 5075336 times.
✓ Branch 8 taken 5075336 times.
86612879 switch(item_type)
2174 {
2175 case itype_clock:
2176 {
2177 5075336 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2178
2179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5075336 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5075336 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2180 return itemsbuf[maxid].fam_type;
2181
2182 5075336 return has_item(itype_clock,1) ? 1 : 0;
2183 }
2184
2185 case itype_key:
2186 5075336 return game->get_keys();
2187
2188 case itype_lkey:
2189 5075336 return game->lvlkeys[get_dlevel()];
2190
2191 case itype_magiccontainer:
2192 5075336 return game->get_maxmagic()/game->get_mp_per_block();
2193
2194 case itype_triforcepiece:
2195 {
2196 5075336 int32_t count=0;
2197
2198
2/2
✓ Branch 0 taken 2598572032 times.
✓ Branch 1 taken 5075336 times.
2603647368 for(int32_t i=0; i<MAXLEVELS; i++)
2199 {
2200 2598572032 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2201 2598572032 }
2202
2203 5075336 return count;
2204 }
2205
2206 case itype_map:
2207 {
2208 5075336 int32_t count=0;
2209
2210
2/2
✓ Branch 0 taken 2598572032 times.
✓ Branch 1 taken 5075336 times.
2603647368 for(int32_t i=0; i<MAXLEVELS; i++)
2211 {
2212 2598572032 count+=(game->lvlitems[i]&liMAP)?1:0;
2213 2598572032 }
2214
2215 5075336 return count;
2216 }
2217
2218 case itype_compass:
2219 {
2220 5075336 int32_t count=0;
2221
2222
2/2
✓ Branch 0 taken 2598572032 times.
✓ Branch 1 taken 5075336 times.
2603647368 for(int32_t i=0; i<MAXLEVELS; i++)
2223 {
2224 2598572032 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2225 2598572032 }
2226
2227 5075336 return count;
2228 }
2229
2230 case itype_bosskey:
2231 {
2232 5075336 int32_t count=0;
2233
2234
2/2
✓ Branch 0 taken 2598572032 times.
✓ Branch 1 taken 5075336 times.
2603647368 for(int32_t i=0; i<MAXLEVELS; i++)
2235 {
2236 2598572032 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2237 2598572032 }
2238
2239 5075336 return count;
2240 }
2241
2242 default:
2243 46010191 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2244
2245
2/2
✓ Branch 0 taken 8708246 times.
✓ Branch 1 taken 37301945 times.
46010191 if(maxid == -1)
2246 37301945 return 0;
2247
2248 8708246 return itemsbuf[maxid].fam_type;
2249 }
2250 86612879 }
2251
2252 79898238 int32_t current_item(int32_t item_type) //item currently being used
2253 {
2254 79898238 return current_item(item_type, true);
2255 }
2256
2257 34 std::map<int32_t, int32_t> itemcache;
2258
2259 // Not actually used by anything at the moment...
2260 void removeFromItemCache(int32_t itemclass)
2261 {
2262 itemcache.erase(itemclass);
2263 }
2264
2265 24266 void flushItemCache()
2266 {
2267 24266 itemcache.clear();
2268
2269 //also fix the active subscreen if items were deleted -DD
2270
1/2
✓ Branch 0 taken 24266 times.
✗ Branch 1 not taken.
24266 if(game != NULL)
2271 {
2272 24266 verifyBothWeapons();
2273 24266 load_Sitems(&QMisc);
2274 24266 }
2275 24266 }
2276
2277 // This is used often, so it should be as direct as possible.
2278 2828860196 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2279 {
2280
2/2
✓ Branch 0 taken 2770412429 times.
✓ Branch 1 taken 58447767 times.
2828860196 if(jinx_check)
2281 {
2282
4/4
✓ Branch 0 taken 38286565 times.
✓ Branch 1 taken 20161202 times.
✓ Branch 2 taken 34622901 times.
✓ Branch 3 taken 3663664 times.
58447767 if(!(HeroSwordClk() || HeroItemClk()))
2283 34622901 jinx_check = false; //not jinxed
2284 58447767 }
2285
4/4
✓ Branch 0 taken 2804651607 times.
✓ Branch 1 taken 24208589 times.
✓ Branch 2 taken 23650363 times.
✓ Branch 3 taken 2781001244 times.
2828860196 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2286 {
2287 2781001244 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2288
2289
2/2
✓ Branch 0 taken 2768612627 times.
✓ Branch 1 taken 12388617 times.
2781001244 if(res != itemcache.end())
2290 2768612627 return res->second;
2291 12388617 }
2292
2293 60247569 int32_t result = -1;
2294 60247569 int32_t highestlevel = -1;
2295
2296
2/2
✓ Branch 0 taken 15423377664 times.
✓ Branch 1 taken 60247569 times.
15483625233 for(int32_t i=0; i<MAXITEMS; i++)
2297 {
2298
5/6
✓ Branch 0 taken 1197918266 times.
✓ Branch 1 taken 14225459398 times.
✓ Branch 2 taken 17819112 times.
✓ Branch 3 taken 1180099154 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17819112 times.
15423377664 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2299 {
2300
4/4
✓ Branch 0 taken 5189620 times.
✓ Branch 1 taken 12629492 times.
✓ Branch 2 taken 1358167 times.
✓ Branch 3 taken 16460945 times.
17819112 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2301 {
2302 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2303
2/2
✓ Branch 0 taken 16460788 times.
✓ Branch 1 taken 157 times.
16460945 if(!checkmagiccost(i))
2304 {
2305
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 145 times.
157 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2306 12 }
2307 16460800 }
2308
6/6
✓ Branch 0 taken 15432381 times.
✓ Branch 1 taken 2386586 times.
✓ Branch 2 taken 256688 times.
✓ Branch 3 taken 2129898 times.
✓ Branch 4 taken 1627257 times.
✓ Branch 5 taken 759329 times.
17818967 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2309 {
2310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 759329 times.
759329 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2311 759329 continue;
2312 }
2313
2314
2/2
✓ Branch 0 taken 237659 times.
✓ Branch 1 taken 16821979 times.
17059638 if(itemsbuf[i].fam_type >= highestlevel)
2315 {
2316 16821979 highestlevel = itemsbuf[i].fam_type;
2317 16821979 result=i;
2318 16821979 }
2319 17059638 }
2320 15422618190 }
2321
2322
2/2
✓ Branch 0 taken 23824866 times.
✓ Branch 1 taken 36422703 times.
60247569 if(!jinx_check) //Can't cache jinx_check results
2323 36422703 itemcache[itemtype] = result;
2324 60247569 return result;
2325 2828860196 }
2326
2327 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2328 2805352776 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2329 {
2330 2805352776 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2331
2/2
✓ Branch 0 taken 34940347 times.
✓ Branch 1 taken 2770412429 times.
2805352776 if(!jinx_check) //If not already a jinx-immune-only check...
2332 {
2333 //And the player IS jinxed...
2334
4/4
✓ Branch 0 taken 2750516811 times.
✓ Branch 1 taken 19895618 times.
✓ Branch 2 taken 3611802 times.
✓ Branch 3 taken 2746905009 times.
2770412429 if(HeroSwordClk() || HeroItemClk())
2335 {
2336 //Then do a jinx-immune-only check here
2337 23507420 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2338 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2339 //Should NOT need a compat rule, as this should always return -1 in old quests.
2340
2/2
✓ Branch 0 taken 1102644 times.
✓ Branch 1 taken 22404776 times.
23507420 if(ret2 > -1) return ret2;
2341 22404776 }
2342 2769309785 }
2343 2804250132 return ret;
2344 2805352776 }
2345 17660218 int32_t current_item_power(int32_t itemtype)
2346 {
2347 17660218 int32_t result = current_item_id(itemtype,true);
2348
2/2
✓ Branch 0 taken 13150491 times.
✓ Branch 1 taken 4509727 times.
17660218 return (result<0) ? 0 : itemsbuf[result].power;
2349 }
2350
2351 7 int32_t heart_container_id()
2352 {
2353
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2354 {
2355
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2356 {
2357 7 return i;
2358 }
2359 196 }
2360 return -1;
2361 7 }
2362
2363 5075336 int32_t item_tile_mod()
2364 {
2365 5075336 int32_t tile=0;
2366
2367
2/2
✓ Branch 0 taken 1064293 times.
✓ Branch 1 taken 4011043 times.
5075336 if(game->get_bombs())
2368 {
2369 4011043 int32_t itemid = current_item_id(itype_bomb,false);
2370
3/4
✓ Branch 0 taken 3929984 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3929984 times.
4011043 if(itemid > -1 && checkbunny(itemid))
2371 3929984 tile+=itemsbuf[itemid].ltm;
2372 4011043 }
2373
2374
2/2
✓ Branch 0 taken 3904902 times.
✓ Branch 1 taken 1170434 times.
5075336 if(game->get_sbombs())
2375 {
2376 1170434 int32_t itemid = current_item_id(itype_sbomb,false);
2377
3/4
✓ Branch 0 taken 1169006 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1169006 times.
1170434 if(itemid > -1 && checkbunny(itemid))
2378 1169006 tile+=itemsbuf[itemid].ltm;
2379 1170434 }
2380
2381
2/2
✓ Branch 0 taken 4971393 times.
✓ Branch 1 taken 103943 times.
5075336 if(current_item(itype_clock))
2382 {
2383 103943 int32_t itemid =
2384
1/2
✓ Branch 0 taken 103943 times.
✗ Branch 1 not taken.
103943 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2385 ? iClock
2386 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2387
2/4
✓ Branch 0 taken 103943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103943 times.
103943 if(itemid > -1 && checkbunny(itemid))
2388 103943 tile+=itemsbuf[itemid].ltm;
2389 103943 }
2390
2391
2/2
✓ Branch 0 taken 4029424 times.
✓ Branch 1 taken 1045912 times.
5075336 if(current_item(itype_key))
2392 {
2393 1045912 int32_t itemid =
2394
1/2
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
1045912 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2395 ? iKey
2396 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2397
2/4
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1045912 times.
1045912 if(itemid > -1 && checkbunny(itemid))
2398 1045912 tile+=itemsbuf[itemid].ltm;
2399 1045912 }
2400
2401
2/2
✓ Branch 0 taken 4902805 times.
✓ Branch 1 taken 172531 times.
5075336 if(current_item(itype_lkey))
2402 {
2403 172531 int32_t itemid =
2404
2/2
✓ Branch 0 taken 171621 times.
✓ Branch 1 taken 910 times.
172531 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2405 ? iLevelKey
2406 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2407
2/4
✓ Branch 0 taken 172531 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 172531 times.
172531 if(itemid > -1 && checkbunny(itemid))
2408 172531 tile+=itemsbuf[itemid].ltm;
2409 172531 }
2410
2411
2/2
✓ Branch 0 taken 1039860 times.
✓ Branch 1 taken 4035476 times.
5075336 if(current_item(itype_map))
2412 {
2413 4035476 int32_t itemid =
2414
2/2
✓ Branch 0 taken 4034690 times.
✓ Branch 1 taken 786 times.
4035476 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2415 ? iMap
2416 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2417
2/4
✓ Branch 0 taken 4035476 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4035476 times.
4035476 if(itemid > -1 && checkbunny(itemid))
2418 4035476 tile+=itemsbuf[itemid].ltm;
2419 4035476 }
2420
2421
2/2
✓ Branch 0 taken 1017978 times.
✓ Branch 1 taken 4057358 times.
5075336 if(current_item(itype_compass))
2422 {
2423 4057358 int32_t itemid =
2424
2/2
✓ Branch 0 taken 3976299 times.
✓ Branch 1 taken 81059 times.
4057358 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2425 ? iCompass
2426 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2427
2/4
✓ Branch 0 taken 4057358 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4057358 times.
4057358 if(itemid > -1 && checkbunny(itemid))
2428 4057358 tile+=itemsbuf[itemid].ltm;
2429 4057358 }
2430
2431
2/2
✓ Branch 0 taken 3206132 times.
✓ Branch 1 taken 1869204 times.
5075336 if(current_item(itype_bosskey))
2432 {
2433 1869204 int32_t itemid =
2434
1/2
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
1869204 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2435 ? iBossKey
2436 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2437
2/4
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1869204 times.
1869204 if(itemid > -1 && checkbunny(itemid))
2438 1869204 tile+=itemsbuf[itemid].ltm;
2439 1869204 }
2440
2441
2/2
✓ Branch 0 taken 2920221 times.
✓ Branch 1 taken 2155115 times.
5075336 if(current_item(itype_magiccontainer))
2442 {
2443 2155115 int32_t itemid =
2444
2/2
✓ Branch 0 taken 2062128 times.
✓ Branch 1 taken 92987 times.
2155115 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2445 ? iMagicC
2446 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2447
3/4
✓ Branch 0 taken 2155115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 2153245 times.
2155115 if(itemid > -1 && checkbunny(itemid))
2448 2153245 tile+=itemsbuf[itemid].ltm;
2449 2155115 }
2450
2451
2/2
✓ Branch 0 taken 1376043 times.
✓ Branch 1 taken 3699293 times.
5075336 if(current_item(itype_triforcepiece))
2452 {
2453 3699293 int32_t itemid =
2454
1/2
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
3699293 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2455 ? iTriforce
2456 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2457
2/4
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3699293 times.
3699293 if(itemid > -1 && checkbunny(itemid))
2458 3699293 tile+=itemsbuf[itemid].ltm;
2459 3699293 }
2460
2461
2/2
✓ Branch 0 taken 5075336 times.
✓ Branch 1 taken 2598572032 times.
2603647368 for(int32_t i=0; i<itype_max; i++)
2462 {
2463
2/2
✓ Branch 0 taken 2540776448 times.
✓ Branch 1 taken 57795584 times.
2598572032 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2464 {
2465
2/2
✓ Branch 0 taken 1128820 times.
✓ Branch 1 taken 56666764 times.
57795584 switch(i)
2466 {
2467 case itype_bomb:
2468 case itype_sbomb:
2469 case itype_clock:
2470 case itype_key:
2471 case itype_lkey:
2472 case itype_map:
2473 case itype_compass:
2474 case itype_bosskey:
2475 case itype_magiccontainer:
2476 case itype_triforcepiece:
2477 1128820 continue; //already handled
2478 }
2479 56666764 }
2480 2597443212 int32_t itemid = current_item_id(i,false);
2481
2/2
✓ Branch 0 taken 2592367876 times.
✓ Branch 1 taken 5075336 times.
2597443212 if(i == itype_shield)
2482 5075336 itemid = getCurrentShield(false);
2483
2484
4/4
✓ Branch 0 taken 70933328 times.
✓ Branch 1 taken 2526509884 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 70832347 times.
2597443212 if(itemid < 0 || !checkbunny(itemid))
2485 2526610865 continue;
2486
2487 70832347 itemdata const& itm = itemsbuf[itemid];
2488
2489
2/2
✓ Branch 0 taken 66370684 times.
✓ Branch 1 taken 4461663 times.
70832347 switch(itm.family)
2490 {
2491 case itype_shield:
2492
1/2
✓ Branch 0 taken 4461663 times.
✗ Branch 1 not taken.
4461663 if(itm.flags & ITEM_FLAG9) //active shield
2493 {
2494 if(!usingActiveShield(itemid))
2495 {
2496 tile+=itm.misc6; //'Inactive PTM'
2497 continue;
2498 }
2499 }
2500 4461663 break;
2501 }
2502
2503 70832347 tile+=itm.ltm;
2504 70832347 }
2505
2506 5075336 return tile;
2507 }
2508
2509 5075336 int32_t bunny_tile_mod()
2510 {
2511
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 5073466 times.
5075336 if(Hero.BunnyClock())
2512 {
2513 1870 return game->get_bunny_ltm();
2514 }
2515 5073466 return 0;
2516 5075336 }
2517
2518 // Hints are drawn on a separate layer to combo reveals.
2519 16332 void draw_lens_under(BITMAP *dest, bool layer)
2520 {
2521 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2522 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2523 //Lens flag 3: Don't show armos/chest/dive items
2524 //Lens flag 4: Show Raft Paths
2525 //Lens flag 5: Show Invisible Enemies
2526
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2527
2528 16332 int32_t strike_hint_table[11]=
2529 {
2530 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2531 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2532 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2533 };
2534
2535 // int32_t page = tmpscr->cpage;
2536 {
2537 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2538 // int32_t temptimer=0;
2539 16332 int32_t tempitem, tempweapon=0;
2540 16332 strike_hint=strike_hint_table[strike_hint_counter];
2541
2542
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2543 {
2544 492 strike_hint_timer=0;
2545 492 strike_hint_counter=((strike_hint_counter+1)%11);
2546 492 }
2547
2548 16332 ++strike_hint_timer;
2549
2550
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2551 {
2552 2874432 int32_t x = (i & 15) << 4;
2553 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2554 2874432 int32_t tempitemx=-16, tempitemy=-16;
2555 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2556
2557
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2558 {
2559 5748864 int32_t checkflag=0;
2560
2561
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2562 {
2563 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2564 2874432 }
2565 else
2566 {
2567 2874432 checkflag=tmpscr->sflag[i];
2568 }
2569
2570
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2571 {
2572
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2573 {
2574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2575 906 }
2576 else
2577 {
2578 192 checkflag = strike_hint;
2579 }
2580 1098 }
2581
2582
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2583 {
2584 case 0:
2585 case mfZELDA:
2586 case mfPUSHED:
2587 case mfENEMY0:
2588 case mfENEMY1:
2589 case mfENEMY2:
2590 case mfENEMY3:
2591 case mfENEMY4:
2592 case mfENEMY5:
2593 case mfENEMY6:
2594 case mfENEMY7:
2595 case mfENEMY8:
2596 case mfENEMY9:
2597 case mfSINGLE:
2598 case mfSINGLE16:
2599 case mfNOENEMY:
2600 case mfTRAP_H:
2601 case mfTRAP_V:
2602 case mfTRAP_4:
2603 case mfTRAP_LR:
2604 case mfTRAP_UD:
2605 case mfNOGROUNDENEMY:
2606 case mfNOBLOCKS:
2607 case mfSCRIPT1:
2608 case mfSCRIPT2:
2609 case mfSCRIPT3:
2610 case mfSCRIPT4:
2611 case mfSCRIPT5:
2612 case mfSCRIPT6:
2613 case mfSCRIPT7:
2614 case mfSCRIPT8:
2615 case mfSCRIPT9:
2616 case mfSCRIPT10:
2617 case mfSCRIPT11:
2618 case mfSCRIPT12:
2619 case mfSCRIPT13:
2620 case mfSCRIPT14:
2621 case mfSCRIPT15:
2622 case mfSCRIPT16:
2623 case mfSCRIPT17:
2624 case mfSCRIPT18:
2625 case mfSCRIPT19:
2626 case mfSCRIPT20:
2627 case mfPITHOLE:
2628 case mfPITFALLFLOOR:
2629 case mfLAVA:
2630 case mfICE:
2631 case mfICEDAMAGE:
2632 case mfDAMAGE1:
2633 case mfDAMAGE2:
2634 case mfDAMAGE4:
2635 case mfDAMAGE8:
2636 case mfDAMAGE16:
2637 case mfDAMAGE32:
2638 case mfFREEZEALL:
2639 case mfFREZEALLANSFFCS:
2640 case mfFREEZEFFCSOLY:
2641 case mfSCRITPTW1TRIG:
2642 case mfSCRITPTW2TRIG:
2643 case mfSCRITPTW3TRIG:
2644 case mfSCRITPTW4TRIG:
2645 case mfSCRITPTW5TRIG:
2646 case mfSCRITPTW6TRIG:
2647 case mfSCRITPTW7TRIG:
2648 case mfSCRITPTW8TRIG:
2649 case mfSCRITPTW9TRIG:
2650 case mfSCRITPTW10TRIG:
2651 case mfTROWEL:
2652 case mfTROWELNEXT:
2653 case mfTROWELSPECIALITEM:
2654 case mfSLASHPOT:
2655 case mfLIFTPOT:
2656 case mfLIFTORSLASH:
2657 case mfLIFTROCK:
2658 case mfLIFTROCKHEAVY:
2659 case mfDROPITEM:
2660 case mfSPECIALITEM:
2661 case mfDROPKEY:
2662 case mfDROPLKEY:
2663 case mfDROPCOMPASS:
2664 case mfDROPMAP:
2665 case mfDROPBOSSKEY:
2666 case mfSPAWNNPC:
2667 case mfSWITCHHOOK:
2668 case mfSIDEVIEWLADDER:
2669 case mfSIDEVIEWPLATFORM:
2670 case mfNOENEMYSPAWN:
2671 case mfENEMYALL:
2672 case mfNOMIRROR:
2673 case mfUNSAFEGROUND:
2674 case mf168:
2675 case mf169:
2676 case mf170:
2677 case mf171:
2678 case mf172:
2679 case mf173:
2680 case mf174:
2681 case mf175:
2682 case mf176:
2683 case mf177:
2684 case mf178:
2685 case mf179:
2686 case mf180:
2687 case mf181:
2688 case mf182:
2689 case mf183:
2690 case mf184:
2691 case mf185:
2692 case mf186:
2693 case mf187:
2694 case mf188:
2695 case mf189:
2696 case mf190:
2697 case mf191:
2698 case mf192:
2699 case mf193:
2700 case mf194:
2701 case mf195:
2702 case mf196:
2703 case mf197:
2704 case mf198:
2705 case mf199:
2706 case mf200:
2707 case mf201:
2708 case mf202:
2709 case mf203:
2710 case mf204:
2711 case mf205:
2712 case mf206:
2713 case mf207:
2714 case mf208:
2715 case mf209:
2716 case mf210:
2717 case mf211:
2718 case mf212:
2719 case mf213:
2720 case mf214:
2721 case mf215:
2722 case mf216:
2723 case mf217:
2724 case mf218:
2725 case mf219:
2726 case mf220:
2727 case mf221:
2728 case mf222:
2729 case mf223:
2730 case mf224:
2731 case mf225:
2732 case mf226:
2733 case mf227:
2734 case mf228:
2735 case mf229:
2736 case mf230:
2737 case mf231:
2738 case mf232:
2739 case mf233:
2740 case mf234:
2741 case mf235:
2742 case mf236:
2743 case mf237:
2744 case mf238:
2745 case mf239:
2746 case mf240:
2747 case mf241:
2748 case mf242:
2749 case mf243:
2750 case mf244:
2751 case mf245:
2752 case mf246:
2753 case mf247:
2754 case mf248:
2755 case mf249:
2756 case mf250:
2757 case mf251:
2758 case mf252:
2759 case mf253:
2760 case mf254:
2761 case mfEXTENDED:
2762 5706470 break;
2763
2764 case mfPUSHUD:
2765 case mfPUSHLR:
2766 case mfPUSH4:
2767 case mfPUSHU:
2768 case mfPUSHD:
2769 case mfPUSHL:
2770 case mfPUSHR:
2771 case mfPUSHUDNS:
2772 case mfPUSHLRNS:
2773 case mfPUSH4NS:
2774 case mfPUSHUNS:
2775 case mfPUSHDNS:
2776 case mfPUSHLNS:
2777 case mfPUSHRNS:
2778 case mfPUSHUDINS:
2779 case mfPUSHLRINS:
2780 case mfPUSH4INS:
2781 case mfPUSHUINS:
2782 case mfPUSHDINS:
2783 case mfPUSHLINS:
2784 case mfPUSHRINS:
2785
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2786
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2787 {
2788 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2789 }
2790
2791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2792
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2793 {
2794
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2795 {
2796
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2797 {
2798 case cPUSH_HEAVY:
2799 case cPUSH_HW:
2800 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2801 72 tempitemx=x, tempitemy=y;
2802
2803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2804 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2805
2806 72 break;
2807
2808 case cPUSH_HEAVY2:
2809 case cPUSH_HW2:
2810 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2811 63 tempitemx=x, tempitemy=y;
2812
2813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2814 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2815
2816 63 break;
2817 }
2818 1032 }
2819 2438 }
2820
2821 3148 break;
2822
2823 case mfWHISTLE:
2824
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2825 {
2826 tempitem=getItemID(itemsbuf,itype_whistle,1);
2827
2828 if(tempitem<0) break;
2829
2830 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2831 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2832 {
2833 tempitemx=x;
2834 tempitemy=y;
2835 }
2836
2837 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2838 }
2839
2840 2418 break;
2841
2842 //Why is this here?
2843 case mfFAIRY:
2844 case mfMAGICFAIRY:
2845 case mfALLFAIRY:
2846 if(hints)
2847 {
2848 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2849
2850 if(tempitem < 0) break;
2851
2852 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2853 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2854 {
2855 tempitemx=x;
2856 tempitemy=y;
2857 }
2858
2859 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2860 }
2861
2862 break;
2863
2864 case mfANYFIRE:
2865
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2866 {
2867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2868 252 }
2869 else
2870 {
2871 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2872
2873
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2874
2875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2876
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2877 {
2878 189 tempitemx=x;
2879 189 tempitemy=y;
2880 189 }
2881
2882 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2883 }
2884
2885 504 break;
2886
2887 case mfSTRONGFIRE:
2888 if(!hints)
2889 {
2890 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2891 }
2892 else
2893 {
2894 tempitem=getItemID(itemsbuf,itype_candle,2);
2895
2896 if(tempitem<0) break;
2897
2898 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2899 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2900 {
2901 tempitemx=x;
2902 tempitemy=y;
2903 }
2904
2905 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2906 }
2907
2908 break;
2909
2910 case mfMAGICFIRE:
2911 if(!hints)
2912 {
2913 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2914 }
2915 else
2916 {
2917 tempitem=getItemID(itemsbuf,itype_wand,1);
2918
2919 if(tempitem<0) break;
2920
2921 tempweapon=wFire;
2922
2923 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2924 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2925 {
2926 tempitemx=x;
2927 tempitemy=y;
2928 }
2929 else
2930 {
2931 tempweaponx=x;
2932 tempweapony=y;
2933 }
2934
2935 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2936 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2937 }
2938
2939 break;
2940
2941 case mfDIVINEFIRE:
2942 if(!hints)
2943 {
2944 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2945 }
2946 else
2947 {
2948 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2949
2950 if(tempitem<0) break;
2951
2952 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2953 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2954 {
2955 tempitemx=x;
2956 tempitemy=y;
2957 }
2958
2959 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2960 }
2961
2962 break;
2963
2964 case mfARROW:
2965
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2966 {
2967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2968 732 }
2969 else
2970 {
2971 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2972
2973
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2974
2975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2976
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2977 {
2978 61 tempitemx=x;
2979 61 tempitemy=y;
2980 61 }
2981
2982 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2983 }
2984
2985 814 break;
2986
2987 case mfSARROW:
2988 if(!hints)
2989 {
2990 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2991 }
2992 else
2993 {
2994 tempitem=getItemID(itemsbuf,itype_arrow,2);
2995
2996 if(tempitem<0) break;
2997
2998 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2999 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3000 {
3001 tempitemx=x;
3002 tempitemy=y;
3003 }
3004
3005 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3006 }
3007
3008 break;
3009
3010 case mfGARROW:
3011 if(!hints)
3012 {
3013 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3014 }
3015 else
3016 {
3017 tempitem=getItemID(itemsbuf,itype_arrow,3);
3018
3019 if(tempitem<0) break;
3020
3021 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3022 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3023 {
3024 tempitemx=x;
3025 tempitemy=y;
3026 }
3027
3028 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3029 }
3030
3031 break;
3032
3033 case mfBOMB:
3034
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3035 {
3036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3037 16 }
3038 else
3039 {
3040 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3041 17 tempweapon = wLitBomb;
3042
3043 //if (tempitem<0) break;
3044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3045
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3046 {
3047 12 tempweaponx=x;
3048 12 tempweapony=y;
3049 12 }
3050
3051 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3052 }
3053
3054 33 break;
3055
3056 case mfSBOMB:
3057
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3058 {
3059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3060 48 }
3061 else
3062 {
3063 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3064 //if (tempitem<0) break;
3065 48 tempweapon = wLitSBomb;
3066
3067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3068
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3069 {
3070 36 tempweaponx=x;
3071 36 tempweapony=y;
3072 36 }
3073
3074 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3075 }
3076
3077 96 break;
3078
3079 case mfARMOS_SECRET:
3080
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3081 {
3082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3083 12 }
3084 24 break;
3085
3086 case mfBRANG:
3087
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3088 {
3089 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3090 }
3091 else
3092 {
3093 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3094
3095
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3096
3097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3098
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3099 {
3100 4 tempitemx=x;
3101 4 tempitemy=y;
3102 4 }
3103
3104 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3105 }
3106
3107 5 break;
3108
3109 case mfMBRANG:
3110 if(!hints)
3111 {
3112 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3113 }
3114 else
3115 {
3116 tempitem=getItemID(itemsbuf,itype_brang,2);
3117
3118 if(tempitem<0) break;
3119
3120 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3121 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3122 {
3123 tempitemx=x;
3124 tempitemy=y;
3125 }
3126
3127 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3128 }
3129
3130 break;
3131
3132 case mfFBRANG:
3133 if(!hints)
3134 {
3135 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3136 }
3137 else
3138 {
3139 tempitem=getItemID(itemsbuf,itype_brang,3);
3140
3141 if(tempitem<0) break;
3142
3143 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3144 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3145 {
3146 tempitemx=x;
3147 tempitemy=y;
3148 }
3149
3150 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3151 }
3152
3153 break;
3154
3155 case mfWANDMAGIC:
3156 if(!hints)
3157 {
3158 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3159 }
3160 else
3161 {
3162 tempitem=getItemID(itemsbuf,itype_wand,1);
3163
3164 if(tempitem<0) break;
3165
3166 tempweapon=itemsbuf[tempitem].wpn3;
3167
3168 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3169 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3170 {
3171 tempitemx=x;
3172 tempitemy=y;
3173 }
3174 else
3175 {
3176 tempweaponx=x;
3177 tempweapony=y;
3178 --lens_hint_weapon[wMagic][4];
3179
3180 if(lens_hint_weapon[wMagic][4]<-8)
3181 {
3182 lens_hint_weapon[wMagic][4]=8;
3183 }
3184 }
3185
3186 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3187 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3188 }
3189
3190 break;
3191
3192 case mfREFMAGIC:
3193
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3194 {
3195 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3196 }
3197 else
3198 {
3199 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3200
3201
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3202
3203 16 tempweapon=ewMagic;
3204
3205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3206
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3207 {
3208 13 tempitemx=x;
3209 13 tempitemy=y;
3210 13 }
3211 else
3212 {
3213 3 tempweaponx=x;
3214 3 tempweapony=y;
3215
3216
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3217 {
3218 1 --lens_hint_weapon[ewMagic][4];
3219 1 }
3220 else
3221 {
3222 2 ++lens_hint_weapon[ewMagic][4];
3223 }
3224
3225
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3226 {
3227 lens_hint_weapon[ewMagic][2]=up;
3228 }
3229
3230
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3231 {
3232 2 lens_hint_weapon[ewMagic][2]=down;
3233 2 }
3234 }
3235
3236 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3237 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3238 }
3239
3240 16 break;
3241
3242 case mfREFFIREBALL:
3243
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3244 {
3245 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3246 }
3247 else
3248 {
3249 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3250
3251
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3252
3253 16 tempweapon=ewFireball;
3254
3255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3256
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3257 {
3258 12 tempitemx=x;
3259 12 tempitemy=y;
3260 12 tempweaponx=x;
3261 12 tempweapony=y;
3262 12 ++lens_hint_weapon[ewFireball][3];
3263
3264
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3265 {
3266 1 lens_hint_weapon[ewFireball][3]=-8;
3267 1 lens_hint_weapon[ewFireball][4]=8;
3268 1 }
3269
3270
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3271 {
3272 8 ++lens_hint_weapon[ewFireball][4];
3273 8 }
3274 else
3275 {
3276 4 --lens_hint_weapon[ewFireball][4];
3277 }
3278 12 }
3279
3280 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3281 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3282 }
3283
3284 16 break;
3285
3286 case mfSWORD:
3287
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3288 {
3289 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3290 }
3291 else
3292 {
3293 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3294
3295
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3296
3297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3298
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3299 {
3300 5 tempitemx=x;
3301 5 tempitemy=y;
3302 5 }
3303
3304 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3305 }
3306
3307 7 break;
3308
3309 case mfWSWORD:
3310 if(!hints)
3311 {
3312 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3313 }
3314 else
3315 {
3316 tempitem=getItemID(itemsbuf,itype_sword,2);
3317
3318 if(tempitem<0) break;
3319
3320 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3321 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3322 {
3323 tempitemx=x;
3324 tempitemy=y;
3325 }
3326
3327 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3328 }
3329
3330 break;
3331
3332 case mfMSWORD:
3333 if(!hints)
3334 {
3335 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3336 }
3337 else
3338 {
3339 tempitem=getItemID(itemsbuf,itype_sword,3);
3340
3341 if(tempitem<0) break;
3342
3343 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3344 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3345 {
3346 tempitemx=x;
3347 tempitemy=y;
3348 }
3349
3350 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3351 }
3352
3353 break;
3354
3355 case mfXSWORD:
3356 if(!hints)
3357 {
3358 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3359 }
3360 else
3361 {
3362 tempitem=getItemID(itemsbuf,itype_sword,4);
3363
3364 if(tempitem<0) break;
3365
3366 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3367 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3368 {
3369 tempitemx=x;
3370 tempitemy=y;
3371 }
3372
3373 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3374 }
3375
3376 break;
3377
3378 case mfSWORDBEAM:
3379
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3380 {
3381 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3382 }
3383 else
3384 {
3385 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3386
3387
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3388
3389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3390
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3391 {
3392 11 tempitemx=x;
3393 11 tempitemy=y;
3394 11 }
3395
3396 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3397 }
3398
3399 16 break;
3400
3401 case mfWSWORDBEAM:
3402 if(!hints)
3403 {
3404 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3405 }
3406 else
3407 {
3408 tempitem=getItemID(itemsbuf,itype_sword,2);
3409
3410 if(tempitem<0) break;
3411
3412 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3413 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3414 {
3415 tempitemx=x;
3416 tempitemy=y;
3417 }
3418
3419 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3420 }
3421
3422 break;
3423
3424 case mfMSWORDBEAM:
3425 if(!hints)
3426 {
3427 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3428 }
3429 else
3430 {
3431 tempitem=getItemID(itemsbuf,itype_sword,3);
3432
3433 if(tempitem<0) break;
3434
3435 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3436 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3437 {
3438 tempitemx=x;
3439 tempitemy=y;
3440 }
3441
3442 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3443 }
3444
3445 break;
3446
3447 case mfXSWORDBEAM:
3448 if(!hints)
3449 {
3450 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3451 }
3452 else
3453 {
3454 tempitem=getItemID(itemsbuf,itype_sword,4);
3455
3456 if(tempitem<0) break;
3457
3458 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3459 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3460 {
3461 tempitemx=x;
3462 tempitemy=y;
3463 }
3464
3465 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3466 }
3467
3468 break;
3469
3470 case mfHOOKSHOT:
3471
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3472 {
3473 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3474 }
3475 else
3476 {
3477 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3478
3479
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3480
3481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3482
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3483 {
3484 12 tempitemx=x;
3485 12 tempitemy=y;
3486 12 }
3487
3488 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3489 }
3490
3491 17 break;
3492
3493 case mfWAND:
3494
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3495 {
3496 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3497 }
3498 else
3499 {
3500 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3501
3502
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3503
3504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3505
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3506 {
3507 28 tempitemx=x;
3508 28 tempitemy=y;
3509 28 }
3510
3511 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3512 }
3513
3514 35 break;
3515
3516 case mfHAMMER:
3517
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3518 {
3519 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3520 }
3521 else
3522 {
3523 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3524
3525
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3526
3527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3528
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3529 {
3530 13 tempitemx=x;
3531 13 tempitemy=y;
3532 13 }
3533
3534 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3535 }
3536
3537 17 break;
3538
3539 case mfARMOS_ITEM:
3540 case mfDIVE_ITEM:
3541
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3542 {
3543 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3544 2064 }
3545 2064 break;
3546
3547 case 16:
3548 case 17:
3549 case 18:
3550 case 19:
3551 case 20:
3552 case 21:
3553 case 22:
3554 case 23:
3555 case 24:
3556 case 25:
3557 case 26:
3558 case 27:
3559 case 28:
3560 case 29:
3561 case 30:
3562 case 31:
3563
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3565 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3566
3567 3618 break;
3568 case mfSECRETSNEXT:
3569 if(!hints)
3570 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3571 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3572
3573 break;
3574
3575 case mfSTRIKE:
3576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3577 {
3578 906 goto special;
3579 }
3580 else
3581 {
3582 break;
3583 }
3584
3585 28640 default: goto special;
3586
3587 special:
3588
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3589 {
3590
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3591 {
3592 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3593 4913 }
3594 6549 }
3595
3596 29546 break;
3597 }
3598 5748864 }
3599 2874432 }
3600
3601
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3602 {
3603
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3604 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3605
3606
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3607 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3608
3609
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3610 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3611
3612
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3613 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3614
3615
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3616 {
3617 43 showbombeddoor(dest, 0);
3618 43 }
3619
3620
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3621 {
3622 39 showbombeddoor(dest, 1);
3623 39 }
3624
3625
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3626 {
3627 showbombeddoor(dest, 2);
3628 }
3629
3630
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3631 {
3632 37 showbombeddoor(dest, 3);
3633 37 }
3634 8166 }
3635
3636
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3637 {
3638
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3639 {
3640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3641 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3642 1123 }
3643 else
3644 {
3645
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3646 {
3647 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3648 48 int32_t tempitemx=-16;
3649 48 int32_t tempitemy=-16;
3650
3651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3652
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3653 {
3654 24 tempitemx=tmpscr->stairx;
3655 24 tempitemy=tmpscr->stairy+playing_field_offset;
3656 24 }
3657
3658 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3659 48 }
3660 }
3661 2034 }
3662 }
3663 16332 }
3664
3665 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3666
3667 7997 void draw_lens_over()
3668 {
3669 // Oh, what the heck.
3670 static BITMAP *lens_scr = NULL;
3671 static int32_t last_width = -1;
3672 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3673
3674 // Only redraw the circle if the size has changed
3675
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3676 {
3677
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3678 {
3679 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3680 5 }
3681
3682 5 clear_to_color(lens_scr, BLACK);
3683 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3684 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3685 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3686 5 last_width=width;
3687 5 }
3688
3689 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3690 7997 }
3691
3692 //----------------------------------------------------------------
3693
3694 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3695 {
3696 //recreating a big bitmap every frame is highly sluggish.
3697
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3698 30701 clear_to_color(wavebuf, BLACK);
3699 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3700
3701 int32_t ofs;
3702 // int32_t amplitude=8;
3703 // int32_t wavelength=4;
3704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3705
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3706 30701 int32_t amp2=168;
3707
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3708 30701 int32_t i=frame%amp2;
3709
3710
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3711 {
3712
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3713 {
3714 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3715 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3716 }
3717 else
3718 {
3719 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3720 }
3721
3722
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3723 {
3724
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3725 {
3726 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3727 1320388608 }
3728 5157768 }
3729 5157768 }
3730 30701 }
3731
3732 3360 void draw_fuzzy(int32_t fuzz)
3733 // draws from right half of scrollbuf to framebuf
3734 {
3735 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3736 byte *start, *si, *di;
3737
3738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if(fuzz<1)
3739 fuzz = 1;
3740
3741 3360 xstep = 128%fuzz;
3742
3743
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 2660 times.
3360 if(xstep > 0)
3744 2660 xstep = fuzz-xstep;
3745
3746 3360 ystep = 112%fuzz;
3747
3748
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 2380 times.
3360 if(ystep > 0)
3749 2380 ystep = fuzz-ystep;
3750
3751 3360 firsty = 1;
3752
3753
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 121240 times.
124600 for(y=0; y<224;)
3754 {
3755 121240 start = &(scrollbuf->line[y][256]);
3756
3757
4/4
✓ Branch 0 taken 119560 times.
✓ Branch 1 taken 754320 times.
✓ Branch 2 taken 752640 times.
✓ Branch 3 taken 121240 times.
873880 for(dy=0; dy<ystep && dy+y<224; dy++)
3758 {
3759 752640 si = start;
3760 752640 di = &(framebuf->line[y+dy][0]);
3761 752640 i = xstep;
3762 752640 firstx = 1;
3763
3764
2/2
✓ Branch 0 taken 192675840 times.
✓ Branch 1 taken 752640 times.
193428480 for(dx=0; dx<256; dx++)
3765 {
3766 192675840 *(di++) = *si;
3767
3768
2/2
✓ Branch 0 taken 162350720 times.
✓ Branch 1 taken 30325120 times.
192675840 if(++i >= fuzz)
3769 {
3770
2/2
✓ Branch 0 taken 29572480 times.
✓ Branch 1 taken 752640 times.
30325120 if(!firstx)
3771 29572480 si += fuzz;
3772 else
3773 {
3774 752640 si += fuzz-xstep;
3775 752640 firstx = 0;
3776 }
3777
3778 30325120 i = 0;
3779 30325120 }
3780 192675840 }
3781 752640 }
3782
3783
2/2
✓ Branch 0 taken 117880 times.
✓ Branch 1 taken 3360 times.
121240 if(!firsty)
3784 117880 y += fuzz;
3785 else
3786 {
3787 3360 y += ystep;
3788 3360 ystep = fuzz;
3789 3360 firsty = 0;
3790 }
3791 }
3792 3360 }
3793
3794 8135987 void updatescr(bool allowwavy)
3795 {
3796
4/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 8135953 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
8135987 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3797
4/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 8135953 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
8135987 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3798
3799
2/2
✓ Branch 0 taken 8110283 times.
✓ Branch 1 taken 25704 times.
8135987 if(toogam)
3800 {
3801 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3802 25704 }
3803
3804
1/2
✓ Branch 0 taken 8135987 times.
✗ Branch 1 not taken.
8135987 if(Showpal)
3805 dump_pal(framebuf);
3806
3807
2/2
✓ Branch 0 taken 7953621 times.
✓ Branch 1 taken 182366 times.
8135987 if(!Playing)
3808 182366 black_opening_count=0;
3809
3810
2/2
✓ Branch 0 taken 8081735 times.
✓ Branch 1 taken 54252 times.
8135987 if(black_opening_count<0) //shape is opening up
3811 {
3812 54252 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3813
3814
2/4
✓ Branch 0 taken 54252 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54252 times.
54252 if(Advance||(!Paused))
3815 {
3816 54252 ++black_opening_count;
3817 54252 }
3818 54252 }
3819
2/2
✓ Branch 0 taken 8061143 times.
✓ Branch 1 taken 20592 times.
8081735 else if(black_opening_count>0) //shape is closing
3820 {
3821 20592 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3822
3823
2/4
✓ Branch 0 taken 20592 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20592 times.
20592 if(Advance||(!Paused))
3824 {
3825 20592 --black_opening_count;
3826 20592 }
3827 20592 }
3828
3829
3/4
✓ Branch 0 taken 8062277 times.
✓ Branch 1 taken 73710 times.
✓ Branch 2 taken 8062277 times.
✗ Branch 3 not taken.
8135987 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3830 {
3831 black_opening_shape = bosCIRCLE;
3832 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3833 refreshTints();
3834 refreshpal=true;
3835 }
3836
3837
2/2
✓ Branch 0 taken 7890965 times.
✓ Branch 1 taken 245022 times.
8135987 if(refreshpal)
3838 {
3839 245022 refreshpal=false;
3840 245022 RAMpal[253] = _RGB(0,0,0);
3841 245022 RAMpal[254] = _RGB(63,63,63);
3842 245022 hw_palette = &RAMpal;
3843 245022 update_hw_pal = true;
3844
3845 245022 create_rgb_table(&rgb_table, RAMpal, NULL);
3846 245022 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3847 245022 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3848
3849
2/2
✓ Branch 0 taken 62725632 times.
✓ Branch 1 taken 245022 times.
62970654 for(int32_t q=0; q<PAL_SIZE; q++)
3850 {
3851 62725632 trans_table2.data[0][q] = q;
3852 62725632 trans_table2.data[q][q] = q;
3853 62725632 }
3854 245022 }
3855
3856 8135987 bool clearwavy = (wavy <= 0);
3857
3858
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 8128742 times.
8135987 if(wavy <= 0)
3859 {
3860 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3861 8128742 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3862 8128742 }
3863
3864 8135987 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3865
3866
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 8105036 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
8135987 if(wavy && Playing && allowwavy)
3867 {
3868 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3869 30701 }
3870
3871
2/2
✓ Branch 0 taken 8128742 times.
✓ Branch 1 taken 7245 times.
8135987 if(clearwavy)
3872 8128742 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3873
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3874 7245 wavy--; // Wavy was set by a script. Decrement it.
3875
3876
5/6
✓ Branch 0 taken 7953621 times.
✓ Branch 1 taken 182366 times.
✓ Branch 2 taken 184496 times.
✓ Branch 3 taken 7769125 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 184496 times.
8135987 if(Playing && msgpos && !screenscrolling)
3877 {
3878
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_bg_display_buf->clip))
3879 184496 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3880
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_portrait_display_buf->clip))
3881 184496 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3882
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_txt_display_buf->clip))
3883 184496 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3884 184496 }
3885
3886 /*
3887 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3888 {
3889 BITMAP* subBmp = 0;
3890 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3891 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3892 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3893 destroy_bitmap(subBmp);
3894 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3895 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3896 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3897 }
3898 */
3899
3900
2/2
✓ Branch 0 taken 8098470 times.
✓ Branch 1 taken 37517 times.
8135987 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3901
3902
2/2
✓ Branch 0 taken 8103095 times.
✓ Branch 1 taken 32892 times.
8135987 if(nosubscr)
3903 {
3904 32892 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3905 32892 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3906 32892 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3907 32892 }
3908
3909 //TODO: Optimize blit 'overcalls' -Gleeok
3910
2/2
✓ Branch 0 taken 32892 times.
✓ Branch 1 taken 8103095 times.
8135987 BITMAP *source = nosubscr ? panorama : wavybuf;
3911 8135987 blit(source,framebuf,0,0,0,0,256,224);
3912
3913 8135987 update_hw_screen();
3914 8135987 }
3915
3916 //----------------------------------------------------------------
3917
3918 static PALETTE syspal;
3919 int32_t onGUISnapshot()
3920 {
3921 char buf[200];
3922 int32_t num=0;
3923 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3924 do
3925 {
3926 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3927 }
3928 while(num<99999 && exists(buf));
3929
3930 BITMAP *b = create_bitmap_ex(8,resx,resy);
3931
3932 if(b)
3933 {
3934 blit(screen,b,0,0,0,0,resx,resy);
3935 save_bitmap(buf,b,RAMpal);
3936 destroy_bitmap(b);
3937 }
3938
3939 return D_O_K;
3940 }
3941
3942 int32_t onNonGUISnapshot()
3943 {
3944 PALETTE temppal;
3945 get_palette(temppal);
3946 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3947
3948 char buf[200];
3949 int32_t num=0;
3950
3951 do
3952 {
3953 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3954 }
3955 while(num<99999 && exists(buf));
3956
3957 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3958
3959 return D_O_K;
3960 }
3961
3962 int32_t onSnapshot()
3963 {
3964 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3965 {
3966 onGUISnapshot();
3967 }
3968 else
3969 {
3970 onNonGUISnapshot();
3971 }
3972
3973 return D_O_K;
3974 }
3975
3976 int32_t onSaveMapPic()
3977 {
3978 int32_t mapres2 = 0;
3979 char buf[200];
3980 int32_t num=0;
3981 mapscr tmpscr_b[2];
3982 mapscr tmpscr_c[6];
3983 BITMAP* _screen_draw_buffer = NULL;
3984 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3985 set_clip_state(_screen_draw_buffer,1);
3986
3987 for(int32_t i=0; i<6; ++i)
3988 {
3989 tmpscr_c[i] = tmpscr2[i];
3990 tmpscr2[i].zero_memory();
3991
3992 if(i>=2)
3993 {
3994 continue;
3995 }
3996
3997 tmpscr_b[i] = tmpscr[i];
3998 tmpscr[i].zero_memory();
3999 }
4000
4001 do
4002 {
4003 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4004 }
4005 while(num<99999 && exists(buf));
4006
4007 BITMAP* mappic = NULL;
4008
4009
4010 bool done=false, redraw=true;
4011
4012 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4013
4014 if(!mappic)
4015 {
4016 enter_sys_pal();
4017 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4018 exit_sys_pal();
4019 return D_O_K;;
4020 }
4021
4022 // draw the map
4023 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4024
4025 for(int32_t y=0; y<8; y++)
4026 {
4027 for(int32_t x=0; x<16; x++)
4028 {
4029 if(!displayOnMap(x, y))
4030 {
4031 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4032 }
4033 else
4034 {
4035 int32_t s = (y<<4) + x;
4036 loadscr2(1,s,-1);
4037
4038 for(int32_t i=0; i<6; i++)
4039 {
4040 if(tmpscr[1].layermap[i]<=0)
4041 continue;
4042
4043 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4044 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4045 {
4046 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4047
4048 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4049 }
4050 }
4051
4052 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4053
4054 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4055
4056 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4057 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4058
4059 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4060
4061 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4062 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4063 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4064 {
4065 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4066 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4067 }
4068 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4069
4070 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4071
4072 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4073 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4074 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4075 {
4076 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4077 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4078 }
4079 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4080 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4081
4082 }
4083
4084 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4085 }
4086 }
4087
4088 for(int32_t i=0; i<6; ++i)
4089 {
4090 tmpscr2[i]=tmpscr_c[i];
4091
4092 if(i>=2)
4093 {
4094 continue;
4095 }
4096
4097 tmpscr[i]=tmpscr_b[i];
4098 }
4099
4100 save_bitmap(buf,mappic,RAMpal);
4101 destroy_bitmap(mappic);
4102 destroy_bitmap(_screen_draw_buffer);
4103 return D_O_K;
4104 }
4105
4106 14 void f_Quit(int32_t type)
4107 {
4108
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4109 return;
4110
4111 14 bool from_menu = is_sys_pal;
4112
4113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4114 {
4115 14 music_pause();
4116 14 pause_all_sfx();
4117 14 sys_mouse();
4118 14 }
4119 14 enter_sys_pal();
4120 14 clear_keybuf();
4121
4122
3/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 13 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4123 13 replay_poll();
4124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4125 14 replay_peek_quit();
4126
4127
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4128 switch(type)
4129 {
4130 case qQUIT:
4131 onQuit();
4132 break;
4133
4134 case qRESET:
4135 onReset();
4136 break;
4137
4138 case qEXIT:
4139 onExit();
4140 break;
4141 }
4142
4143
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4144 {
4145 14 kill_sfx();
4146 14 music_stop();
4147 14 exit_sys_pal();
4148 14 update_hw_screen();
4149 14 }
4150 else
4151 {
4152 exit_sys_pal();
4153 if(!from_menu)
4154 {
4155 music_resume();
4156 resume_all_sfx();
4157 }
4158 }
4159
4160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4161 14 game_mouse();
4162 14 eat_buttons();
4163
4164 14 zc_readrawkey(KEY_ESC);
4165
4166 14 zc_readrawkey(KEY_ENTER);
4167 14 }
4168
4169 //----------------------------------------------------------------
4170
4171 int32_t onNoWalls()
4172 {
4173 cheats_enqueue(Cheat::Walls);
4174 return D_O_K;
4175 }
4176
4177 int32_t onIgnoreSideview()
4178 {
4179 cheats_enqueue(Cheat::IgnoreSideView);
4180 return D_O_K;
4181 }
4182
4183 8135902 int32_t input_idle(bool checkmouse)
4184 {
4185 static int32_t mx, my, mz, mb;
4186
4187
4/6
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2139141 times.
✓ Branch 3 taken 5996761 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2139141 times.
10275043 if(keypressed() || zc_key_pressed() ||
4188
4/8
✓ Branch 0 taken 2139141 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2139141 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2139141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2139141 times.
✗ Branch 7 not taken.
2139141 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4189 {
4190 5996761 idle_count = 0;
4191
4192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5996761 times.
5996761 if(active_count < MAX_ACTIVE)
4193 {
4194 5996761 ++active_count;
4195 5996761 }
4196 5996761 }
4197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2139141 times.
2139141 else if(idle_count < MAX_IDLE)
4198 {
4199 2139141 ++idle_count;
4200 2139141 active_count = 0;
4201 2139141 }
4202
4203 8135902 mx = mouse_x;
4204 8135902 my = mouse_y;
4205 8135902 mz = mouse_z;
4206 8135902 mb = mouse_b;
4207
4208 8135902 return idle_count;
4209 }
4210
4211 int32_t onGoFast()
4212 {
4213 cheats_enqueue(Cheat::Fast);
4214 return D_O_K;
4215 }
4216
4217 int32_t onKillCheat()
4218 {
4219 cheats_enqueue(Cheat::Kill);
4220 return D_O_K;
4221 }
4222
4223 int32_t onSecretsCheat()
4224 {
4225 cheats_enqueue(Cheat::TrigSecrets);
4226 return D_O_K;
4227 }
4228 int32_t onSecretsCheatPerm()
4229 {
4230 cheats_enqueue(Cheat::TrigSecretsPerm);
4231 return D_O_K;
4232 }
4233
4234 int32_t onShowLayer0()
4235 {
4236 show_layer_0 = !show_layer_0;
4237 return D_O_K;
4238 }
4239 int32_t onShowLayer1()
4240 {
4241 show_layer_1 = !show_layer_1;
4242 return D_O_K;
4243 }
4244 int32_t onShowLayer2()
4245 {
4246 show_layer_2 = !show_layer_2;
4247 return D_O_K;
4248 }
4249 int32_t onShowLayer3()
4250 {
4251 show_layer_3 = !show_layer_3;
4252 return D_O_K;
4253 }
4254 int32_t onShowLayer4()
4255 {
4256 show_layer_4 = !show_layer_4;
4257 return D_O_K;
4258 }
4259 int32_t onShowLayer5()
4260 {
4261 show_layer_5 = !show_layer_5;
4262 return D_O_K;
4263 }
4264 int32_t onShowLayer6()
4265 {
4266 show_layer_6 = !show_layer_6;
4267 return D_O_K;
4268 }
4269 int32_t onShowLayerO()
4270 {
4271 show_layer_over=!show_layer_over;
4272 return D_O_K;
4273 }
4274 int32_t onShowLayerP()
4275 {
4276 show_layer_push=!show_layer_push;
4277 return D_O_K;
4278 }
4279 int32_t onShowLayerS()
4280 {
4281 show_sprites=!show_sprites;
4282 return D_O_K;
4283 }
4284 int32_t onShowLayerF()
4285 {
4286 show_ffcs=!show_ffcs;
4287 return D_O_K;
4288 }
4289 int32_t onShowLayerW()
4290 {
4291 show_walkflags=!show_walkflags;
4292 if(show_walkflags)
4293 show_effectflags = false;
4294 return D_O_K;
4295 }
4296 int32_t onShowLayerE()
4297 {
4298 show_effectflags=!show_effectflags;
4299 if(show_effectflags)
4300 show_walkflags = false;
4301 return D_O_K;
4302 }
4303 int32_t onShowFFScripts()
4304 {
4305 show_ff_scripts=!show_ff_scripts;
4306 return D_O_K;
4307 }
4308 int32_t onShowHitboxes()
4309 {
4310 show_hitboxes=!show_hitboxes;
4311 return D_O_K;
4312 }
4313 int32_t onShowInfoOpacity()
4314 {
4315 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4316 zc_set_config("zc","debug_info_opacity",info_opacity);
4317 return D_O_K;
4318 }
4319
4320 int32_t onLightSwitch()
4321 {
4322 cheats_enqueue(Cheat::Light);
4323 return D_O_K;
4324 }
4325
4326 int32_t onGoTo();
4327 int32_t onGoToComplete();
4328
4329 8135902 void syskeys()
4330 {
4331 8135902 update_system_keys();
4332
4333 int32_t oldtitle_version;
4334
4335
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if(close_button_quit)
4336 {
4337 close_button_quit=false;
4338 f_Quit(qEXIT);
4339 }
4340
4341 8135902 poll_joystick();
4342
4343
2/10
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8135902 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8135902 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4344 {
4345 oldtitle_version=title_version;
4346 System();
4347 }
4348
4349 8135902 mouse_down=gui_mouse_b();
4350
4351
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if(zc_read_system_key(KEY_F1))
4352 {
4353 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4354 {
4355 halt=!halt;
4356 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4357 }
4358 else
4359 {
4360 Throttlefps=!Throttlefps;
4361 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4362 logic_counter=0;
4363 }
4364 }
4365
4366 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4367 /*
4368 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4369 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4370 */
4371
4372
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if(zc_read_system_key(KEY_F2))
4373 {
4374 ShowFPS=!ShowFPS;
4375 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4376 }
4377
4378
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8135902 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8135902 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4379
4380
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8135902 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8135902 if(zc_read_system_key(KEY_F4) && Playing)
4381 {
4382 Paused=true;
4383 Advance=true;
4384 }
4385
4386
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if(zc_read_system_key(KEY_F6)) onTryQuit();
4387
4388 #ifndef ALLEGRO_MACOSX
4389
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4390
4391
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4392 #else
4393 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4394
4395 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4396 #endif
4397
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8135902 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8135902 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4398
4399
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if (zc_read_system_key(KEY_F12))
4400 {
4401 onSnapshot();
4402 }
4403
4404
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8135902 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8135902 if(debug_enabled && zc_read_system_key(KEY_TAB))
4405 set_debug(!get_debug());
4406
4407
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if(CheatModifierKeys())
4408 {
4409 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4410 {
4411 if(!bindable_cheat(c))
4412 continue;
4413 if(get_debug() || cheat >= cheat_lvl(c))
4414 {
4415 if(checkcheat(c))
4416 cheats_hit_bind(c);
4417 }
4418 }
4419 }
4420
4421
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if(volkeys)
4422 {
4423 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4424
4425 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4426
4427 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4428
4429 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4430 }
4431
4432
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8135902 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8135902 if(!get_debug() || !SystemKeys || replay_is_replaying())
4433 8135902 goto bottom;
4434
4435 if(zc_readkey(KEY_D))
4436 {
4437 details = !details;
4438 rectfill(screen,0,0,319,7,BLACK);
4439 rectfill(screen,0,8,31,239,BLACK);
4440 rectfill(screen,288,8,319,239,BLACK);
4441 rectfill(screen,32,232,287,239,BLACK);
4442 }
4443
4444 if(zc_readkey(KEY_P)) Paused=!Paused;
4445
4446 //if(zc_readkey(KEY_P)) centerHero();
4447 if(zc_readkey(KEY_A))
4448 {
4449 Paused=true;
4450 Advance=true;
4451 }
4452
4453 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4454 #ifndef ALLEGRO_MACOSX
4455 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4456
4457 if(zc_readkey(KEY_F7))
4458 {
4459 Matrix(ss_speed, ss_density, 0);
4460 game_pal();
4461 }
4462 #else
4463 // The reason these are different on Mac in the first place is that
4464 // the OS doesn't let us use F9 and F10...
4465 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4466
4467 if(zc_readkey(KEY_F9))
4468 {
4469 Matrix(ss_speed, ss_density, 0);
4470 game_pal();
4471 }
4472 #endif
4473 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4474 {
4475 //change containers
4476 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4477 {
4478 //magic containers
4479 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4480 {
4481 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4482 }
4483 else
4484 {
4485 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4486 }
4487 }
4488 else
4489 {
4490 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4491 {
4492 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4493 }
4494 else
4495 {
4496 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4497 }
4498 }
4499 }
4500
4501 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4502 {
4503 //change containers
4504 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4505 {
4506 //magic containers
4507 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4508 {
4509 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4510 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4511 //heart containers
4512 }
4513 else
4514 {
4515 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4516 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4517 }
4518 }
4519 else
4520 {
4521 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4522 {
4523 game->set_magic(zc_max(game->get_magic()-1,0));
4524 }
4525 else
4526 {
4527 game->set_life(zc_max(game->get_life()-1,0));
4528 }
4529 }
4530 }
4531
4532 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4533
4534 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4535
4536 verifyBothWeapons();
4537
4538 bottom:
4539
4540
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if(input_idle(true) > after_time())
4541 {
4542 Matrix(ss_speed, ss_density, 0);
4543 game_pal();
4544 }
4545 8135902 }
4546
4547 425776 void checkQuitKeys()
4548 {
4549 #ifndef ALLEGRO_MACOSX
4550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425776 times.
425776 if(key[KEY_F9]) f_Quit(qRESET);
4551
4552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425776 times.
425776 if(key[KEY_F10]) f_Quit(qEXIT);
4553 #else
4554 if(key[KEY_F7]) f_Quit(qRESET);
4555
4556 if(key[KEY_F8]) f_Quit(qEXIT);
4557 #endif
4558 425776 }
4559
4560 8135902 bool CheatModifierKeys()
4561 {
4562 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4563 // to trigger cheats.
4564
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if (replay_is_replaying())
4565 8135902 return false;
4566
4567 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4568 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4569 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4570 {
4571 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4572 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4573 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4574 {
4575 return true;
4576 }
4577 }
4578 return false;
4579 8135902 }
4580
4581 //99:05:54, for some reason?
4582 #define OLDMAXTIME 21405240
4583 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4584 #define MAXTIME 1944000000
4585
4586 8135987 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4587 {
4588
2/2
✓ Branch 0 taken 7842402 times.
✓ Branch 1 taken 293585 times.
8135987 if(zcmusic!=NULL)
4589 {
4590 293585 zcmusic_poll();
4591 293585 }
4592
4593 8135987 updatescr(allowwavy);
4594
4595 8135987 Advance=false;
4596
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8135987 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8135987 times.
8135987 while(Paused && !Advance && !Quit)
4597 {
4598 // have to call this, otherwise we'll get an infinite loop
4599 syskeys();
4600 if(allowF6Script)
4601 {
4602 FFCore.runF6Engine();
4603 }
4604 throttleFPS();
4605
4606 #ifdef _WIN32
4607
4608 if(use_dwm_flush)
4609 {
4610 do_DwmFlush();
4611 }
4612
4613 #endif
4614
4615 // to keep music playing
4616 if(zcmusic!=NULL)
4617 {
4618 zcmusic_poll();
4619 }
4620
4621 update_hw_screen();
4622 }
4623
4624
2/2
✓ Branch 0 taken 8135914 times.
✓ Branch 1 taken 73 times.
8135987 if(Quit)
4625 73 return;
4626
4627
3/4
✓ Branch 0 taken 7953612 times.
✓ Branch 1 taken 182302 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7953612 times.
8135914 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4628 7953612 game->change_time(1);
4629
4630
3/4
✓ Branch 0 taken 8135914 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1531767 times.
✓ Branch 3 taken 6604147 times.
8135914 if (!replay_is_active() || replay_get_version() >= 11)
4631
2/2
✓ Branch 0 taken 27571806 times.
✓ Branch 1 taken 1531767 times.
29103573 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4632 29103573 down_control_states[i] = raw_control_state[i];
4633
4634
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8135922 times.
8135914 if (replay_is_active())
4635 {
4636
2/2
✓ Branch 0 taken 1270471 times.
✓ Branch 1 taken 6865451 times.
8135922 if (replay_get_version() >= 3)
4637 6865451 replay_poll();
4638
4639
6/6
✓ Branch 0 taken 6604137 times.
✓ Branch 1 taken 1531765 times.
✓ Branch 2 taken 3183485 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 3082950 times.
8135922 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4640 1632300 replay_peek_input();
4641 8135902 }
4642
4643 8135914 load_control_called_this_frame = false;
4644
4645 8135914 poll_keyboard();
4646 8135914 update_keys();
4647
4648 8135914 ++frame;
4649
4650
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8135902 times.
8135914 if (replay_is_replaying())
4651 8135902 replay_do_cheats();
4652 8135914 syskeys();
4653
4654 // The mouse variables can change from the mouse thread at anytime during a frame,
4655 // so save the result at the start so that replaying is consistent.
4656 8135914 script_mouse_x = gui_mouse_x();
4657 8135914 script_mouse_y = gui_mouse_y();
4658 8135914 script_mouse_z = mouse_z;
4659 8135914 script_mouse_b = mouse_b;
4660
4661 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4662 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4663 // approach here means it doesn't matter which call adds the cheat.
4664 8135914 cheats_execute_queued();
4665
4666
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8135902 times.
8135914 if (replay_is_replaying())
4667 8135902 replay_peek_quit();
4668
2/2
✓ Branch 0 taken 8135900 times.
✓ Branch 1 taken 14 times.
8135914 if (GameFlags & GAMEFLAG_TRYQUIT)
4669 14 replay_step_quit(0);
4670
2/2
✓ Branch 0 taken 2932 times.
✓ Branch 1 taken 8132982 times.
8135914 if(allowF6Script)
4671 8132982 FFCore.runF6Engine();
4672
2/2
✓ Branch 0 taken 8135689 times.
✓ Branch 1 taken 225 times.
8135914 if (Quit)
4673 225 replay_step_quit(Quit);
4674 // Someday... maybe install a Turbo button here?
4675 8135914 throttleFPS();
4676
4677 #ifdef _WIN32
4678
4679 if(use_dwm_flush)
4680 {
4681 do_DwmFlush();
4682 }
4683
4684 #endif
4685
4686 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4687
2/2
✓ Branch 0 taken 46694 times.
✓ Branch 1 taken 8089220 times.
8135914 if(sfxcleanup)
4688 8089220 sfx_cleanup();
4689 8135987 }
4690
4691 70 void zapout()
4692 {
4693 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4694 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4695
4696 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4697 70 script_drawing_commands.Clear();
4698
4699 // zap out
4700
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=1; i<=24; i++)
4701 {
4702 1680 draw_fuzzy(i);
4703 1680 advanceframe(true);
4704
4705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4706 {
4707 break;
4708 }
4709 1680 }
4710 70 }
4711
4712 70 void zapin()
4713 {
4714 70 FFCore.warpScriptCheck();
4715 70 draw_screen(tmpscr);
4716 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4717 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4718 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4719
4720 // zap out
4721 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4722
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=24; i>=1; i--)
4723 {
4724 1680 draw_fuzzy(i);
4725 1680 advanceframe(true);
4726
4727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4728 {
4729 break;
4730 }
4731 1680 }
4732 70 }
4733
4734
4735 38 void wavyout(bool showhero)
4736 {
4737 38 draw_screen(tmpscr, showhero);
4738 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4739
4740 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4741 38 clear_to_color(wavebuf,0);
4742 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4743
4744 static PALETTE wavepal;
4745
4746 int32_t ofs;
4747 38 int32_t amplitude=8;
4748
4749 38 int32_t wavelength=4;
4750 38 double palpos=0, palstep=4, palstop=126;
4751
4752 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4753
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4754 {
4755
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4756 {
4757 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4758 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4759 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4760 408576 }
4761
4762 1596 palpos+=palstep;
4763
4764
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4765 {
4766 1596 hw_palette = &wavepal;
4767 1596 update_hw_pal = true;
4768 1596 }
4769 else
4770 {
4771 hw_palette = &RAMpal;
4772 update_hw_pal = true;
4773 }
4774
4775
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4776 {
4777
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4778 {
4779 68640768 ofs=0;
4780
4781
4/4
✓ Branch 0 taken 33503232 times.
✓ Branch 1 taken 35137536 times.
✓ Branch 2 taken 16751616 times.
✓ Branch 3 taken 16751616 times.
68640768 if((j<i)&&(j&1))
4782 {
4783 16751616 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4784 16751616 }
4785
4786 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4787 68640768 }
4788 268128 }
4789
4790 1596 advanceframe(true);
4791
4792 // animate_combos();
4793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4794 break;
4795 1596 }
4796
4797 38 destroy_bitmap(wavebuf);
4798 38 }
4799
4800 38 void wavyin()
4801 {
4802 38 draw_screen(tmpscr);
4803 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4804
4805 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4806 38 clear_to_color(wavebuf,0);
4807 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4808
4809 static PALETTE wavepal;
4810
4811 //Breaks dark rooms.
4812 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4813 /*
4814 loadfullpal();
4815 loadlvlpal(DMaps[currdmap].color);
4816 ringcolor(false);
4817 */
4818 38 refreshpal=false;
4819 int32_t ofs;
4820 38 int32_t amplitude=8;
4821 38 int32_t wavelength=4;
4822 38 double palpos=168, palstep=4, palstop=126;
4823
4824 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4825
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4826 {
4827
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4828 {
4829 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4830 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4831 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4832 408576 }
4833
4834 1596 palpos-=palstep;
4835
4836
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4837 {
4838 1596 hw_palette = &wavepal;
4839 1596 update_hw_pal = true;
4840 1596 }
4841 else
4842 {
4843 hw_palette = &RAMpal;
4844 update_hw_pal = true;
4845 }
4846
4847
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4848 {
4849
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4850 {
4851 68640768 ofs=0;
4852
4853
4/4
✓ Branch 0 taken 34728960 times.
✓ Branch 1 taken 33911808 times.
✓ Branch 2 taken 17568768 times.
✓ Branch 3 taken 17160192 times.
68640768 if((j<(167-i))&&(j&1))
4854 {
4855 17160192 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4856 17160192 }
4857
4858 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4859 68640768 }
4860 268128 }
4861
4862 1596 advanceframe(true);
4863 // animate_combos();
4864
4865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4866 break;
4867 1596 }
4868
4869 38 destroy_bitmap(wavebuf);
4870 38 }
4871
4872 1922 void blackscr(int32_t fcnt,bool showsubscr)
4873 {
4874 1922 reset_pal_cycling();
4875 1922 script_drawing_commands.Clear();
4876
4877 1922 FFCore.warpScriptCheck();
4878 1922 bool showtime = game->should_show_time();
4879
2/2
✓ Branch 0 taken 1922 times.
✓ Branch 1 taken 57590 times.
59512 while(fcnt>0)
4880 {
4881 57590 clear_bitmap(framebuf);
4882
4883
2/2
✓ Branch 0 taken 19740 times.
✓ Branch 1 taken 37850 times.
57590 if(showsubscr)
4884 {
4885 37850 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
4886
3/4
✓ Branch 0 taken 37850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 37100 times.
37850 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4887 {
4888 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4889 750 }
4890 37850 }
4891
4892 57590 advanceframe(true);
4893
4894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57590 times.
57590 if(Quit)
4895 break;
4896
4897 57590 --fcnt;
4898 }
4899 1922 }
4900
4901 726 void openscreen(int32_t shape)
4902 {
4903 726 reset_pal_cycling();
4904 726 black_opening_count=0;
4905
4906
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 627 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
726 if(COOLSCROLL || shape>-1)
4907 {
4908 627 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4909 627 return;
4910 }
4911 else
4912 {
4913 99 Hero.setDontDraw(true);
4914 99 show_subscreen_dmap_dots=false;
4915 99 show_subscreen_numbers=false;
4916 // show_subscreen_items=false;
4917 99 show_subscreen_life=false;
4918 }
4919
4920 99 int32_t x=128;
4921
4922 99 FFCore.warpScriptCheck();
4923
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 7920 times.
8019 for(int32_t i=0; i<80; i++)
4924 {
4925 7920 draw_screen(tmpscr);
4926 //? draw_screen already draws the subscreen -DD
4927 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4928 7920 x=128-(((i*128/80)/8)*8);
4929
4930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7920 times.
7920 if(x>0)
4931 {
4932 7920 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4933 7920 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4934 7920 }
4935
4936 7920 advanceframe(true);
4937
4938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7920 times.
7920 if(Quit)
4939 {
4940 break;
4941 }
4942 7920 }
4943
4944 99 Hero.setDontDraw(false);
4945 99 show_subscreen_items=true;
4946 99 show_subscreen_dmap_dots=true;
4947 726 }
4948
4949 void closescreen(int32_t shape)
4950 {
4951 reset_pal_cycling();
4952 black_opening_count=0;
4953
4954 if(COOLSCROLL || shape>-1)
4955 {
4956 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4957 return;
4958 }
4959 else
4960 {
4961 Hero.setDontDraw(true);
4962 show_subscreen_dmap_dots=false;
4963 show_subscreen_numbers=false;
4964 // show_subscreen_items=false;
4965 show_subscreen_life=false;
4966 }
4967
4968 int32_t x=128;
4969
4970 FFCore.warpScriptCheck();
4971 for(int32_t i=79; i>=0; --i)
4972 {
4973 draw_screen(tmpscr);
4974 //? draw_screen already draws the subscreen -DD
4975 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4976 x=128-(((i*128/80)/8)*8);
4977
4978 if(x>0)
4979 {
4980 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4981 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4982 }
4983
4984 advanceframe(true);
4985
4986 if(Quit)
4987 {
4988 break;
4989 }
4990 }
4991
4992 Hero.setDontDraw(false);
4993 show_subscreen_items=true;
4994 show_subscreen_dmap_dots=true;
4995 }
4996
4997 179 int32_t TriforceCount()
4998 {
4999 179 int32_t c=0;
5000
5001
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5002
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5003 1044 ++c;
5004
5005 179 return c;
5006 }
5007
5008 int32_t onCustomGame()
5009 {
5010 int32_t file = getsaveslot();
5011
5012 if(file < 0)
5013 return D_O_K;
5014
5015 bool ret = (custom_game(file)!=0);
5016 return ret ? D_CLOSE : D_O_K;
5017 }
5018
5019 int32_t onContinue()
5020 {
5021 return D_CLOSE;
5022 }
5023
5024 int32_t onEsc() // Unused?? -L
5025 {
5026 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5027 }
5028
5029 int32_t onVsync()
5030 {
5031 Throttlefps = !Throttlefps;
5032 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5033 return D_O_K;
5034 }
5035
5036 int32_t onWinPosSave()
5037 {
5038 SaveWinPos = !SaveWinPos;
5039 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5040 return D_O_K;
5041 }
5042 int32_t onIntegerScaling()
5043 {
5044 scaleForceInteger = !scaleForceInteger;
5045 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5046 return D_O_K;
5047 }
5048 int32_t onStretchGame()
5049 {
5050 stretchGame = !stretchGame;
5051 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5052 return D_O_K;
5053 }
5054
5055 int32_t onClickToFreeze()
5056 {
5057 ClickToFreeze = !ClickToFreeze;
5058 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5059 return D_O_K;
5060 }
5061
5062 int32_t OnSaveZCConfig()
5063 {
5064 if(jwin_alert3(
5065 "Save Configuration",
5066 "Are you sure that you wish to save your present configuration settings?",
5067 "This will overwrite your prior settings!",
5068 NULL,
5069 "&Yes",
5070 "&No",
5071 NULL,
5072 'y',
5073 'n',
5074 0,
5075 get_zc_font(font_lfont)) == 1)
5076 {
5077 save_game_configs();
5078 return D_O_K;
5079 }
5080 else return D_O_K;
5081 }
5082
5083 int32_t OnnClearQuestDir()
5084 {
5085 if(jwin_alert3(
5086 "Clear Current Directory Cache",
5087 "Are you sure that you wish to clear the current cached directory?",
5088 "This will default the current directory to the ROOT for this instance of ZC Player!",
5089 NULL,
5090 "&Yes",
5091 "&No",
5092 NULL,
5093 'y',
5094 'n',
5095 0,
5096 get_zc_font(font_lfont)) == 1)
5097 {
5098 zc_set_config("zeldadx","win_qst_dir","");
5099 flush_config_file();
5100 strcpy(qstdir,"");
5101 #ifdef __EMSCRIPTEN__
5102 em_sync_fs();
5103 #endif
5104 return D_O_K;
5105 }
5106 else return D_O_K;
5107 }
5108
5109
5110 int32_t onConsoleZASM()
5111 {
5112 if ( !zasm_debugger )
5113 {
5114 AlertDialog("WARNING: ZASM Debugger",
5115 "Enabling this will open the ZASM Debugger Console"
5116 "\nThis will likely grind ZC to a halt with lag."
5117 "\nTo make any use of this, it is suggested that you read"
5118 "\nthe documentation for 'void Breakpoint(char[] string);'"
5119 " in 'ZScript_Additions.txt'"
5120 "\nThis is not recommended for normal users,"
5121 " and is only intended for ZC developers,"
5122 "\nor quest developers coding directly in ZASM"
5123 "\nAre you sure that you wish to open the ZASM Debugger?",
5124 [&](bool ret,bool)
5125 {
5126 if(ret)
5127 {
5128 FFCore.ZASMPrint(true);
5129 }
5130 }).show();
5131 return D_O_K;
5132 }
5133 else
5134 {
5135 FFCore.ZASMPrint(false);
5136 return D_O_K;
5137 }
5138 }
5139
5140
5141 int32_t onConsoleZScript()
5142 {
5143 if ( !zscript_debugger )
5144 {
5145 AlertDialog("ZScript Debugger",
5146 "Enabling this will open the ZScript Debugger Console"
5147 "\nThis will display any messages logged by scripts,"
5148 " including script errors."
5149 "\nAre you sure that you wish to open the ZScript Debugger?",
5150 [&](bool ret,bool)
5151 {
5152 if(ret)
5153 {
5154 FFCore.ZScriptConsole(true);
5155 }
5156 }).show();
5157 return D_O_K;
5158 }
5159 else
5160 {
5161 FFCore.ZScriptConsole(false);
5162 return D_O_K;
5163 }
5164 }
5165
5166 int32_t onClrConsoleOnReload()
5167 {
5168 clearConsoleOnReload = !clearConsoleOnReload;
5169 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5170 return D_O_K;
5171 }
5172 int32_t onClrConsoleOnLoad()
5173 {
5174 clearConsoleOnLoad = !clearConsoleOnLoad;
5175 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5176 return D_O_K;
5177 }
5178
5179
5180 int32_t onFrameSkip()
5181 {
5182 FrameSkip = !FrameSkip;
5183 return D_O_K;
5184 }
5185
5186 int32_t onSaveDragResize()
5187 {
5188 SaveDragResize = !SaveDragResize;
5189 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5190 return D_O_K;
5191 }
5192
5193 int32_t onDragAspect()
5194 {
5195 DragAspect = !DragAspect;
5196 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5197 return D_O_K;
5198 }
5199
5200 int32_t onTransLayers()
5201 {
5202 TransLayers = !TransLayers;
5203 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5204 return D_O_K;
5205 }
5206
5207 int32_t onNESquit()
5208 {
5209 NESquit = !NESquit;
5210 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5211 return D_O_K;
5212 }
5213
5214 int32_t onVolKeys()
5215 {
5216 volkeys = !volkeys;
5217 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5218 return D_O_K;
5219 }
5220
5221 int32_t onShowFPS()
5222 {
5223 ShowFPS = !ShowFPS;
5224 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5225 return D_O_K;
5226 }
5227
5228 960036436 bool is_Fkey(int32_t k)
5229 {
5230
2/2
✓ Branch 0 taken 97630824 times.
✓ Branch 1 taken 862405612 times.
960036436 switch(k)
5231 {
5232 case KEY_F1:
5233 case KEY_F2:
5234 case KEY_F3:
5235 case KEY_F4:
5236 case KEY_F5:
5237 case KEY_F6:
5238 case KEY_F7:
5239 case KEY_F8:
5240 case KEY_F9:
5241 case KEY_F10:
5242 case KEY_F11:
5243 case KEY_F12:
5244 97630824 return true;
5245 }
5246
5247 862405612 return false;
5248 960036436 }
5249
5250 void kb_getkey(DIALOG *d);
5251
5252 //Used by all keyboard key settings dialogues.
5253 void kb_clearjoystick(DIALOG *d)
5254 {
5255 d->flags|=D_SELECTED;
5256
5257 jwin_button_proc(MSG_DRAW,d,0);
5258 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5259 // text_mode(vc(11));
5260 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5261 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5262
5263 update_hw_screen(true);
5264
5265 clear_keybuf();
5266 int32_t k = next_press_key();
5267 clear_keybuf();
5268
5269 //shnarf
5270 //47=f1
5271 //59=esc
5272 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5273 // *((int32_t*)d->dp3) = k;
5274 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5275
5276
5277 d->flags&=~D_SELECTED;
5278 }
5279
5280 //Clears key to 0.
5281 //Used by all keyboard key settings dialogues.
5282 void kb_clearkey(DIALOG *d);
5283
5284 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5285 {
5286 switch(msg)
5287 {
5288 case MSG_KEY:
5289 case MSG_CLICK:
5290
5291 kb_clearjoystick(d);
5292
5293 while(gui_mouse_b())
5294 {
5295 clear_keybuf();
5296 rest(1);
5297 }
5298
5299 return D_REDRAW;
5300 }
5301
5302 return jwin_button_proc(msg,d,c);
5303 }
5304
5305 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5306 //Only used in keyboard settings dialogues to clear keys.
5307 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5308
5309 void j_getbtn(DIALOG *d)
5310 {
5311 d->flags|=D_SELECTED;
5312 jwin_button_proc(MSG_DRAW,d,0);
5313 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5314 // text_mode(vc(11));
5315 int32_t y = gui_bmp->h/2 - 12;
5316 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5317 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5318 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5319
5320 update_hw_screen(true);
5321
5322 int32_t b = next_press_btn();
5323
5324 if(b>=0)
5325 *((int32_t*)d->dp3) = b;
5326
5327 d->flags&=~D_SELECTED;
5328
5329 if (player)
5330 player->joy_on = TRUE;
5331 }
5332
5333 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5334 {
5335 switch(msg)
5336 {
5337 case MSG_KEY:
5338 case MSG_CLICK:
5339
5340 j_getbtn(d);
5341
5342 while(gui_mouse_b()) {
5343 rest(1);
5344 clear_keybuf();
5345 }
5346
5347 return D_REDRAW;
5348 }
5349
5350 return jwin_button_proc(msg,d,c);
5351 }
5352
5353 //shnarf
5354 extern const char *key_str[];
5355 std::string get_keystr(int key);
5356
5357 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5358 //extern int32_t zcmusic_bufsz;
5359
5360 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5361 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5362
5363 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5364 {
5365 //these are here to bypass compiler warnings about unused arguments
5366 c=c;
5367
5368 if(msg==MSG_DRAW)
5369 {
5370 switch(d->w)
5371 {
5372 case 0:
5373 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5374 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5375 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5376 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5377 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5378 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5379 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5380 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5381 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5382 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5383 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5384 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5385 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5386 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5387 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5388 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5389 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5390 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5391 break;
5392
5393 case 1:
5394 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5395 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5396 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5397 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5398 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5399 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5400 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5401 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5402 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5403 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5404 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5405 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5406 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5407 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5408 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5409 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5410 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5411 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5412 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5413 break;
5414
5415 case 2:
5416 sprintf(str_a," %3d",midi_volume);
5417 sprintf(str_b," %3d",digi_volume);
5418 sprintf(str_l," %3d",emusic_volume);
5419 sprintf(str_m," %3dKB",zcmusic_bufsz);
5420 sprintf(str_r," %3d",sfx_volume);
5421 strcpy(str_s,pan_str[pan_style]);
5422 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5423 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5424 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5425 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5426 break;
5427 }
5428 }
5429
5430 return D_O_K;
5431 }
5432
5433 int32_t set_vol(void *dp3, int32_t d2)
5434 {
5435 switch(((int32_t*)dp3)[0])
5436 {
5437 case 0:
5438 midi_volume = zc_min(d2<<3,255);
5439 break;
5440
5441 case 1:
5442 digi_volume = zc_min(d2<<3,255);
5443 break;
5444
5445 case 2:
5446 emusic_volume = zc_min(d2<<3,255);
5447 break;
5448
5449 case 3:
5450 sfx_volume = zc_min(d2<<3,255);
5451 break;
5452 }
5453
5454 // text_mode(vc(11));
5455 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5456 return D_O_K;
5457 }
5458
5459 int32_t set_pan(void *dp3, int32_t d2)
5460 {
5461 pan_style = vbound(d2,0,3);
5462 // text_mode(vc(11));
5463 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5464 return D_O_K;
5465 }
5466
5467 int32_t set_buf(void *dp3, int32_t d2)
5468 {
5469 // text_mode(vc(11));
5470 zcmusic_bufsz = d2 + 1;
5471 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5472 return D_O_K;
5473 }
5474
5475 static int32_t gamepad_btn_list[] =
5476 {
5477 6,
5478 7,8,9,10,11,12,13,14,15,16,17,
5479 18,19,20,21,22,23,24,25,26,27,28,
5480 29,30,31,32,33,34,35,36,37,38,39,
5481 -1
5482 };
5483
5484 static int32_t gamepad_dirs_list[] =
5485 {
5486 40,41,42,43,
5487 44,45,46,47,
5488 48,49,50,51,
5489 52,53,54,55,
5490 56,
5491 -1
5492 };
5493
5494 static TABPANEL gamepad_tabs[] =
5495 {
5496 // (text)
5497 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5498 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5499 { NULL, 0, NULL, 0, NULL }
5500 };
5501
5502 static DIALOG gamepad_dlg[] =
5503 {
5504 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5505 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5506 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5507 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5508 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5509 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5510 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5511 // 6
5512 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5513 // 7
5514 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5515 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5516 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5517 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5518 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5519 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5520 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5521 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5522 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5523 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5524 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5525 // 18
5526 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5527 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5528 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5529 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5530 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5531 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5532 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5533 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5534 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5535 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5536 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5537 // 29
5538 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5539 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5540 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5541 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5542 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5543 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5544 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5545 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5546 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5547 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5548 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5549 // 40
5550 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5551 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5552 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5553 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5554 // 44
5555 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5556 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5557 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5558 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5559 // 48
5560 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5561 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5562 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5563 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5564 // 52
5565 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5566 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5567 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5568 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5569 // 56
5570 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5571 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5572 };
5573
5574 static int32_t keyboard_keys_list[] =
5575 {
5576 6,7,8,9,10,
5577 11,12,13,14,15,16,17,18,19,20,
5578 21,22,23,24,25,26,27,28,29,30,
5579 31,32,33,34,35,36,37,38,39,40,
5580 -1
5581 };
5582
5583 static int32_t keyboard_dirs_list[] =
5584 {
5585 41,42,43,44,
5586 45,46,47,48,
5587 49,50,51,52,
5588 53,54,55,56,
5589 -1
5590 };
5591
5592 static int32_t keyboard_mods_list[] =
5593 {
5594 57,58,59,60,
5595 61,62,63,64,
5596 65,66,67,68,
5597 69,70,71,72,
5598 -1
5599 };
5600
5601 static TABPANEL keyboard_control_tabs[] =
5602 {
5603 // (text)
5604 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5605 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5606 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5607 { NULL, 0, NULL, 0, NULL }
5608 };
5609
5610 static DIALOG keyboard_control_dlg[] =
5611 {
5612 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5613 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5614 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5615 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5616 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5617 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5618 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5619 // Keys
5620 // 6
5621 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5622 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5623 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5624 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5625 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5626 // 11
5627 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5628 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5629 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5630 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5631 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5632 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5633 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5634 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5635 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5636 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5637 // 21
5638 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5639 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5640 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5641 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5642 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5643 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5644 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5645 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5646 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5647 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5648 // 31
5649 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5650 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5651 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5652 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5653 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5654 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5655 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5656 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5657 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5658 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5659 // Dirs
5660 // 41
5661 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5662 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5663 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5664 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5665 // 45
5666 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5667 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5668 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5669 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5670 // 49
5671 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5672 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5673 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5674 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5675 // 53
5676 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5677 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5678 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5679 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5680 // Mods
5681 // 57
5682 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5683 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5684 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5685 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5686 // 61
5687 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5688 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5689 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5690 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5691 // 65
5692 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5693 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5694 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5695 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5696 // 69
5697 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5698 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5699 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5700 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5701 // 73
5702 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5703 };
5704
5705 /*
5706 int32_t midi_dp[3] = {0,147,104};
5707 int32_t digi_dp[3] = {1,147,120};
5708 int32_t pan_dp[3] = {0,147,136};
5709 int32_t buf_dp[3] = {0,147,152};
5710 */
5711 int32_t midi_dp[3] = {0,0,0};
5712 int32_t digi_dp[3] = {1,0,0};
5713 int32_t emus_dp[3] = {2,0,0};
5714 int32_t buf_dp[3] = {0,0,0};
5715 int32_t sfx_dp[3] = {3,0,0};
5716 int32_t pan_dp[3] = {0,0,0};
5717
5718 static DIALOG sound_dlg[] =
5719 {
5720 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5721 34 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5722 34 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5723 34 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5724 34 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5725 34 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5726 34 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5727 34 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5728 34 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5729 34 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5730 34 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5731 // 10
5732 34 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5733 34 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5734 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5735 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5736 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5737 34 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5738 34 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5739 34 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5740 34 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5741 34 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5742 //20
5743 34 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5744 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5745 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5746 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5747 34 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5748 34 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5749 34 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5750 34 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5751 34 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5752 34 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5753 //30
5754 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5755 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5756 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5757 34 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5758 };
5759
5760 char zc_builddate[80];
5761 char zc_aboutstr[80];
5762
5763 static DIALOG about_dlg[] =
5764 {
5765 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5766 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5767 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5768 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5769 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5770 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5771 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5772 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5773 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5774 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5775 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5776 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5777 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5778 };
5779
5780
5781 static DIALOG quest_dlg[] =
5782 {
5783 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5784 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5785 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5786 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5787 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5788 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5789 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5790 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5791 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5792 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5793 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5794 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5795 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5796 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5797 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5798 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5799 };
5800
5801 static DIALOG triforce_dlg[] =
5802 {
5803 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5804 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5805 // 1
5806 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5807 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5808 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5809 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5810 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5811 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5812 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5813 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5814 // 9
5815 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5816 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5817 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5818 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5819 };
5820
5821 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5822 {
5823 go();
5824 int32_t ret=0;
5825 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5826 comeback();
5827 return ret != 0;
5828 }
5829
5830
5831 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5832 {
5833 if(def!=modulepath)
5834 strcpy(modulepath,def);
5835
5836 if(!usefilename)
5837 {
5838 int32_t i=(int32_t)strlen(modulepath);
5839
5840 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5841 modulepath[i--]=0;
5842 }
5843
5844 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5845 int32_t ret=0;
5846 int32_t sel=0;
5847
5848 if(list==NULL)
5849 {
5850 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5851 }
5852 else
5853 {
5854 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5855 }
5856
5857 return ret!=0;
5858 }
5859
5860 //The Dialogue that loads a ZMOD Module File
5861 int32_t zc_load_zmod_module_file()
5862 {
5863 if ( Playing )
5864 {
5865 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5866 return -1;
5867 }
5868 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5869 return D_CLOSE;
5870
5871 FILE *tempmodule = fopen(modulepath,"r");
5872
5873 if(tempmodule == NULL)
5874 {
5875 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5876 return -1;
5877 }
5878
5879
5880 //Set the module path:
5881 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5882 strcpy(moduledata.module_name, modulepath);
5883 al_trace("New Module Path is: %s \n", moduledata.module_name);
5884 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
5885 zcm.init(true); //Load the module values.
5886 moduledata.refresh_title_screen = 1;
5887 // refresh_select_screen = 1;
5888 build_biic_list();
5889 return D_O_K;
5890 }
5891
5892 static DIALOG module_info_dlg[] =
5893 {
5894 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
5895
5896
5897 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
5898 //1
5899 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
5900 //2
5901 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5902 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
5903 //4
5904 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5905 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5906 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
5907 //7
5908
5909 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5910 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5911 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5912 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5913 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5914 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5915 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5916 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5917 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5918
5919 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5920 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5921 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5922 };
5923
5924 void about_zcplayer_module(const char *prompt,int32_t initialval)
5925 {
5926
5927 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
5928 if ( moduledata.moduletitle[0] != 0 )
5929 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
5930
5931 if ( moduledata.moduleauthor[0] != 0 )
5932 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
5933
5934 if ( moduledata.moduleinfo0[0] != 0 )
5935 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
5936 if ( moduledata.moduleinfo1[0] != 0 )
5937 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
5938 if ( moduledata.moduleinfo2[0] != 0 )
5939 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
5940 if ( moduledata.moduleinfo3[0] != 0 )
5941 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
5942 if ( moduledata.moduleinfo4[0] != 0 )
5943 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
5944
5945 char module_date[255];
5946 memset(module_date, 0, sizeof(module_date));
5947 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
5948 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
5949
5950
5951
5952 char module_vers[255];
5953 memset(module_vers, 0, sizeof(module_vers));
5954 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
5955
5956
5957 //sprintf(tilecount,"%d",1);
5958
5959 char module_build[255];
5960 memset(module_build, 0, sizeof(module_build));
5961 if ( moduledata.modbeta )
5962 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
5963 else
5964 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
5965
5966 module_info_dlg[12].dp = (char*)module_date;
5967 module_info_dlg[13].dp = (char*)module_vers;
5968 module_info_dlg[14].dp = (char*)module_build;
5969
5970 large_dialog(module_info_dlg);
5971
5972 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
5973 jwin_center_dialog(module_info_dlg);
5974
5975
5976 }
5977
5978 int32_t onAbout_ZCP_Module()
5979 {
5980 about_zcplayer_module("About Module (.zmod)", 0);
5981 return D_O_K;
5982 }
5983
5984 //New Modules Menu for 2.55+
5985 static MENU zcmodule_menu[] =
5986 {
5987 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
5988 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
5989
5990 { NULL, NULL, NULL, 0, NULL }
5991 };
5992
5993 int32_t onToggleRecordingNewSaves()
5994 {
5995 if (zc_get_config("zeldadx", "replay_new_saves", false))
5996 {
5997 zc_set_config("zeldadx", "replay_new_saves", false);
5998 }
5999 else
6000 {
6001 zc_set_config("zeldadx", "replay_new_saves", true);
6002 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6003 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6004 }
6005 return D_O_K;
6006 }
6007
6008 int32_t onToggleSnapshotAllFrames()
6009 {
6010 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6011 return D_O_K;
6012 }
6013
6014 int32_t onStopReplayOrRecord()
6015 {
6016 if (replay_is_replaying())
6017 {
6018 replay_quit();
6019 }
6020 else if (replay_get_mode() == ReplayMode::Record)
6021 {
6022 if (!replay_get_meta_bool("test_mode"))
6023 {
6024 jwin_alert("Recording", "You cannot stop recording a save file.",
6025 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6026 return D_CLOSE;
6027 }
6028
6029 if (jwin_alert("Stop Recording",
6030 "Save replay to disk and stop recording?",
6031 "This will stop the recording.",
6032 NULL,
6033 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6034 return D_CLOSE;
6035
6036 replay_save();
6037 replay_stop();
6038 }
6039 return D_O_K;
6040 }
6041
6042 static int32_t handle_on_load_replay(ReplayMode mode)
6043 {
6044 if (Playing)
6045 {
6046 if (jwin_alert("Replay - Warning!",
6047 "Loading a replay will exit the current game.",
6048 "All unsaved progress will be lost.",
6049 "Do you wish to continue?",
6050 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6051 return D_CLOSE;
6052 }
6053
6054 std::string mode_string = replay_mode_to_string(mode);
6055 mode_string[0] = std::toupper(mode_string[0]);
6056
6057 std::string line_1 = "Select a replay file to play back.";
6058 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6059 std::string line_3 = "You can stop the replay and take over manually any time.";
6060 if (mode == ReplayMode::Update)
6061 {
6062 line_1 = "Select a replay file to update.";
6063 line_2 = "WARNING: be sure to back up the zplay file";
6064 line_3 = "and verify that the updated replay works as expected!";
6065 }
6066
6067 if (jwin_alert(mode_string.c_str(),
6068 line_1.c_str(),
6069 line_2.c_str(),
6070 line_3.c_str(),
6071 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6072 {
6073 char replay_path[2048];
6074 strcpy(replay_path, "replays/");
6075 if (jwin_file_select_ex(
6076 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6077 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6078 return D_CLOSE;
6079
6080 replay_quit();
6081 load_replay_file_deferred(mode, replay_path);
6082 Quit = qRESET;
6083 return D_CLOSE;
6084 }
6085 return D_O_K;
6086 }
6087
6088 int32_t onLoadReplay()
6089 {
6090 return handle_on_load_replay(ReplayMode::Replay);
6091 }
6092
6093 int32_t onLoadReplayAssert()
6094 {
6095 return handle_on_load_replay(ReplayMode::Assert);
6096 }
6097
6098 int32_t onLoadReplayUpdate()
6099 {
6100 return handle_on_load_replay(ReplayMode::Update);
6101 }
6102
6103 int32_t onSaveReplay()
6104 {
6105 if (replay_get_mode() == ReplayMode::Record)
6106 {
6107 if (!replay_get_meta_bool("test_mode"))
6108 {
6109 if (jwin_alert("Save Replay",
6110 "This will save a copy of the replay up to this point.",
6111 "The official replay file will be untouched.",
6112 "Do you wish to continue?",
6113 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6114 return D_CLOSE;
6115
6116 char replay_path[2048];
6117 strcpy(replay_path, replay_get_replay_path().string().c_str());
6118 if (jwin_file_select_ex(
6119 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6120 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6121 return D_CLOSE;
6122
6123 if (fileexists(replay_path))
6124 {
6125 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6126 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6127 return D_CLOSE;
6128 }
6129
6130 replay_save(replay_path);
6131 }
6132 else
6133 {
6134 replay_save();
6135 }
6136 }
6137 return D_O_K;
6138 }
6139
6140 static MENU replay_menu[] =
6141 {
6142 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6143 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6144 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6145 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6146 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6147 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6148 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6149
6150 { NULL, NULL, NULL, 0, NULL }
6151 };
6152
6153 static DIALOG credits_dlg[] =
6154 {
6155 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6156 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6157 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6158 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6159 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6160 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6161 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6162 };
6163
6164 34 static ListData dmap_list(dmaplist, &font);
6165
6166 static DIALOG goto_dlg[] =
6167 {
6168 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6169 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6170 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6171 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6172 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6173 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6174 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6175 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6176 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6177 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6178 };
6179
6180 int32_t onGoTo()
6181 {
6182 bool music = false;
6183 music = music;
6184 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6185
6186 goto_dlg[0].dp2=get_zc_font(font_lfont);
6187 goto_dlg[4].d2=cheat_goto_dmap;
6188 goto_dlg[6].dp=cheat_goto_screen_str;
6189
6190 clear_keybuf();
6191
6192 large_dialog(goto_dlg);
6193
6194 if(zc_popup_dialog(goto_dlg,4)==1)
6195 {
6196 // dmap, screen
6197 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6198 };
6199
6200 return D_O_K;
6201 }
6202
6203 int32_t onGoToComplete()
6204 {
6205 if(!Playing)
6206 {
6207 return D_O_K;
6208 }
6209
6210 enter_sys_pal();
6211 music_pause();
6212 pause_all_sfx();
6213 onGoTo();
6214 eat_buttons();
6215
6216 zc_readrawkey(KEY_ESC);
6217
6218 exit_sys_pal();
6219 music_resume();
6220 resume_all_sfx();
6221 return D_O_K;
6222 }
6223
6224 int32_t onCredits()
6225 {
6226 go();
6227
6228 BITMAP *win = create_bitmap_ex(8,222,110);
6229
6230 if(!win)
6231 return D_O_K;
6232
6233 int32_t c=0;
6234 int32_t l=0;
6235 int32_t ol=-1;
6236 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6237 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6238 PALETTE tmppal;
6239
6240 rti_gui.transparency_index = 1;
6241
6242 clear_to_color(win, rti_gui.transparency_index);
6243 draw_rle_sprite(win,rle,0,0);
6244 credits_dlg[0].dp2=get_zc_font(font_lfont);
6245 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6246 credits_dlg[2].dp = win;
6247
6248 zc_set_palette_range(black_palette,0,127,false);
6249
6250 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6251
6252 BITMAP* old_screen = screen;
6253 BITMAP* gui_bmp = zc_get_gui_bmp();
6254 ASSERT(gui_bmp);
6255 clear_to_color(gui_bmp, rti_gui.transparency_index);
6256 screen = gui_bmp;
6257
6258 while(update_dialog(p))
6259 {
6260 throttleFPS();
6261 ++c;
6262 l = zc_max((c>>1)-30,0);
6263
6264 if(l > rle->h)
6265 l = c = 0;
6266
6267 if(l > rle->h - 112)
6268 l = rle->h - 112;
6269
6270 clear_bitmap(win);
6271 draw_rle_sprite(win,rle,0,0-l);
6272
6273 if(c<=64)
6274 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6275
6276 zc_set_palette_range(tmppal,0,127,false);
6277
6278 if(l!=ol)
6279 {
6280 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6281 SCRFIX();
6282 ol=l;
6283 }
6284
6285 update_hw_screen();
6286 }
6287
6288 screen = old_screen;
6289 system_pal(true);
6290 sys_mouse();
6291
6292 shutdown_dialog(p);
6293 destroy_bitmap(win);
6294 //comeback();
6295
6296 rti_gui.transparency_index = 0;
6297 clear_to_color(gui_bmp, rti_gui.transparency_index);
6298
6299 return D_O_K;
6300 }
6301
6302 const char *midilist(int32_t index, int32_t *list_size)
6303 {
6304 if(index<0)
6305 {
6306 *list_size=0;
6307
6308 for(int32_t i=0; i<MAXMIDIS; i++)
6309 if(tunes[i].data)
6310 ++(*list_size);
6311
6312 return NULL;
6313 }
6314
6315 int32_t i=0,m=0;
6316
6317 while(m<=index && i<=MAXMIDIS)
6318 {
6319 if(tunes[i].data)
6320 ++m;
6321
6322 ++i;
6323 }
6324
6325 --i;
6326
6327 if(i==MAXMIDIS && m<index)
6328 return "(null)";
6329
6330 return tunes[i].title;
6331 }
6332
6333 /* ------- MIDI info stuff -------- */
6334
6335 char *text;
6336 midi_info *zmi;
6337 bool dialog_running;
6338 bool listening;
6339
6340 void get_info(int32_t index);
6341
6342 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6343 {
6344 int32_t d2 = d->d2;
6345 int32_t ret = jwin_droplist_proc(msg,d,c);
6346
6347 if(d2!=d->d2)
6348 {
6349 get_info(d->d2);
6350 }
6351
6352 return ret;
6353 }
6354
6355 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6356 {
6357 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6358
6359 int32_t ret = jwin_button_proc(msg,d,c);
6360
6361 if(ret == D_CLOSE)
6362 {
6363 // get current midi index
6364 int32_t index = (d+(d->d1))->d2;
6365 int32_t i=0, m=0;
6366
6367 while(m<=index && i<=MAXMIDIS)
6368 {
6369 if(tunes[i].data)
6370 ++m;
6371
6372 ++i;
6373 }
6374
6375 --i;
6376 jukebox(i);
6377 listening = true;
6378 ret = D_O_K;
6379 }
6380
6381 return ret;
6382 }
6383
6384 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6385 {
6386 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6387
6388 int32_t ret = jwin_button_proc(msg,d,c);
6389
6390 if(ret == D_CLOSE)
6391 {
6392 // get current midi index
6393 int32_t index = (d+(d->d1))->d2;
6394 int32_t i=0, m=0;
6395
6396 while(m<=index && i<=MAXMIDIS)
6397 {
6398 if(tunes[i].data)
6399 ++m;
6400
6401 ++i;
6402 }
6403
6404 --i;
6405
6406 // get file name
6407
6408 int32_t sel=0;
6409 //struct ffblk f;
6410 char title[40] = "Save MIDI: ";
6411 char fname[2048];
6412 memset(fname,0,2048);
6413 static EXT_LIST list[] =
6414 {
6415 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6416 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6417 { NULL, NULL }
6418 };
6419
6420 strcpy(title+11, tunes[i].title);
6421 title[39] = '\0';
6422
6423 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6424 goto done;
6425
6426 if(exists(fname))
6427 {
6428 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6429 goto done;
6430 }
6431
6432 // save midi i
6433
6434 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6435 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6436
6437 done:
6438 chop_path(fname);
6439 ret = D_REDRAW;
6440 }
6441
6442 return ret;
6443 }
6444
6445 34 static ListData midi_list(midilist, &font);
6446
6447 static DIALOG midi_dlg[] =
6448 {
6449 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6450 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6451 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6452 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6453 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6454 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6455 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6456 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6457 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6458 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6459 };
6460
6461 void get_info(int32_t index)
6462 {
6463 int32_t i=0, m=0;
6464
6465 while(m<=index && i<=MAXMIDIS)
6466 {
6467 if(tunes[i].data)
6468 ++m;
6469
6470 ++i;
6471 }
6472
6473 --i;
6474
6475 if(i==MAXMIDIS && m<index)
6476 strcpy(text,"(null)");
6477 else
6478 {
6479 get_midi_info((MIDI*)tunes[i].data,zmi);
6480 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6481 }
6482
6483 midi_dlg[0].dp2=get_zc_font(font_lfont);
6484 midi_dlg[3].dp = text;
6485 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6486 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6487
6488 if(dialog_running)
6489 {
6490 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6491 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6492 }
6493 }
6494
6495 int32_t onMIDICredits()
6496 {
6497 text = (char*)malloc(4096);
6498 zmi = (midi_info*)malloc(sizeof(midi_info));
6499
6500 if(!text || !zmi)
6501 {
6502 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6503 return D_O_K;
6504 }
6505
6506 bool do_pause_midi = midi_pos >= 0 && currmidi;
6507 auto restore_midi = currmidi;
6508 if(do_pause_midi)
6509 {
6510 paused_midi_pos = midi_pos;
6511 stop_midi();
6512 midi_paused=true;
6513 midi_suspended = midissuspHALTED;
6514 }
6515
6516 midi_dlg[0].dp2=get_zc_font(font_lfont);
6517 midi_dlg[2].d1 = 0;
6518 midi_dlg[2].d2 = 0;
6519 midi_dlg[4].flags = D_EXIT;
6520 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6521
6522 listening = false;
6523 dialog_running=false;
6524 get_info(0);
6525
6526 dialog_running=true;
6527
6528 large_dialog(midi_dlg);
6529
6530 zc_popup_dialog(midi_dlg,0);
6531 dialog_running=false;
6532
6533 if(listening)
6534 music_stop();
6535
6536 if(do_pause_midi)
6537 {
6538 midi_suspended = midissuspRESUME;
6539 currmidi = restore_midi;
6540 midi_pos = paused_midi_pos;
6541 }
6542
6543 if(text) free(text);
6544 if(zmi) free(zmi);
6545 return D_O_K;
6546 }
6547
6548 int32_t onAbout()
6549 {
6550 char buf1[80]={0};
6551 std::ostringstream oss;
6552 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6553 oss << buf1 << '\n';
6554 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6555 oss << buf1 << '\n';
6556 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6557 oss << buf1 << '\n';
6558 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6559 oss << buf1 << '\n';
6560 sprintf(buf1, "Tag: %s", getReleaseTag());
6561 oss << buf1 << '\n';
6562
6563 InfoDialog("About ZC", oss.str()).show();
6564 return D_O_K;
6565 }
6566
6567 int32_t onQuest()
6568 {
6569 char fname[100];
6570 strcpy(fname, get_filename(qstpath));
6571 quest_dlg[0].dp2=get_zc_font(font_lfont);
6572 quest_dlg[1].dp = fname;
6573
6574 if(QHeader.quest_number==0)
6575 sprintf(str_a,"Custom");
6576 else
6577 sprintf(str_a,"%d",QHeader.quest_number);
6578
6579 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6580
6581 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6582 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6583
6584 large_dialog(quest_dlg);
6585
6586 zc_popup_dialog(quest_dlg, 0);
6587 return D_O_K;
6588 }
6589
6590 void call_vidmode_dlg();
6591 int32_t onVidMode()
6592 {
6593 call_vidmode_dlg();
6594 return D_O_K;
6595 }
6596
6597 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6598 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6599 //Added an extra statement, so that if the key is cleared to 0, the cleared
6600 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6601
6602 void load_ukeys(int32_t* arr)
6603 {
6604 arr[ukey_a] = Akey;
6605 arr[ukey_b] = Bkey;
6606 arr[ukey_s] = Skey;
6607 arr[ukey_l] = Lkey;
6608 arr[ukey_r] = Rkey;
6609 arr[ukey_p] = Pkey;
6610 arr[ukey_ex1] = Exkey1;
6611 arr[ukey_ex2] = Exkey2;
6612 arr[ukey_ex3] = Exkey3;
6613 arr[ukey_ex4] = Exkey4;
6614 arr[ukey_du] = DUkey;
6615 arr[ukey_dd] = DDkey;
6616 arr[ukey_dl] = DLkey;
6617 arr[ukey_dr] = DRkey;
6618 arr[ukey_mod1a] = cheat_modifier_keys[0];
6619 arr[ukey_mod1b] = cheat_modifier_keys[1];
6620 arr[ukey_mod2a] = cheat_modifier_keys[2];
6621 arr[ukey_mod2b] = cheat_modifier_keys[3];
6622 };
6623
6624 static const char* ukey_names[] = {
6625 "A", "B", "Start", "L", "R", "Map",
6626 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6627 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6628 "Cheat Mod R1", "Cheat Mod R2",
6629 };
6630 std::string get_ukey_name(int32_t k)
6631 {
6632 if (k < num_ukey) return ukey_names[k];
6633 return "";
6634 }
6635
6636 int32_t onKeyboard()
6637 {
6638 int32_t a = Akey;
6639 int32_t b = Bkey;
6640 int32_t s = Skey;
6641 int32_t l = Lkey;
6642 int32_t r = Rkey;
6643 int32_t p = Pkey;
6644 int32_t ex1 = Exkey1;
6645 int32_t ex2 = Exkey2;
6646 int32_t ex3 = Exkey3;
6647 int32_t ex4 = Exkey4;
6648 int32_t du = DUkey;
6649 int32_t dd = DDkey;
6650 int32_t dl = DLkey;
6651 int32_t dr = DRkey;
6652 int32_t mod1a = cheat_modifier_keys[0];
6653 int32_t mod1b = cheat_modifier_keys[1];
6654 int32_t mod2a = cheat_modifier_keys[2];
6655 int32_t mod2b = cheat_modifier_keys[3];
6656 bool done=false;
6657 int32_t ret;
6658
6659 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6660
6661 large_dialog(keyboard_control_dlg);
6662
6663 while(!done)
6664 {
6665 ret = zc_popup_dialog(keyboard_control_dlg,3);
6666
6667 if(ret==3) // OK
6668 {
6669 int32_t ukeys[num_ukey];
6670 load_ukeys(ukeys);
6671 std::vector<std::string> uniqueError;
6672 for(int32_t q = 0; q < num_ukey; ++q)
6673 {
6674 for(int32_t p = q+1; p < num_ukey; ++p)
6675 {
6676 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6677 {
6678 char buf[64];
6679 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6680 std::string str(buf);
6681 uniqueError.push_back(str);
6682 }
6683 }
6684 }
6685 if(uniqueError.size() == 0)
6686 {
6687 done = true;
6688 save_control_configs(true);
6689 }
6690 else
6691 {
6692 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6693 box_out("Cannot have duplicate keybinds!"); box_eol();
6694 for(std::vector<std::string>::iterator it = uniqueError.begin();
6695 it != uniqueError.end(); ++it)
6696 {
6697 box_out((*it).c_str()); box_eol();
6698 }
6699 box_end(true);
6700 }
6701 }
6702 else // Cancel
6703 {
6704 Akey = a;
6705 Bkey = b;
6706 Skey = s;
6707 Lkey = l;
6708 Rkey = r;
6709 Pkey = p;
6710 Exkey1 = ex1;
6711 Exkey2 = ex2;
6712 Exkey3 = ex3;
6713 Exkey4 = ex4;
6714 DUkey = du;
6715 DDkey = dd;
6716 DLkey = dl;
6717 DRkey = dr;
6718 cheat_modifier_keys[0] = mod1a;
6719 cheat_modifier_keys[1] = mod1b;
6720 cheat_modifier_keys[2] = mod2a;
6721 cheat_modifier_keys[3] = mod2b;
6722
6723 done=true;
6724 }
6725
6726 rest(1);
6727 }
6728
6729 return D_O_K;
6730 }
6731
6732 int32_t onGamepad()
6733 {
6734 int32_t a = Abtn;
6735 int32_t b = Bbtn;
6736 int32_t s = Sbtn;
6737 int32_t l = Lbtn;
6738 int32_t r = Rbtn;
6739 int32_t m = Mbtn;
6740 int32_t p = Pbtn;
6741 int32_t ex1 = Exbtn1;
6742 int32_t ex2 = Exbtn2;
6743 int32_t ex3 = Exbtn3;
6744 int32_t ex4 = Exbtn4;
6745 int32_t up = DUbtn;
6746 int32_t down = DDbtn;
6747 int32_t left = DLbtn;
6748 int32_t right = DRbtn;
6749
6750 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6751 if(analog_movement)
6752 gamepad_dlg[56].flags|=D_SELECTED;
6753 else
6754 gamepad_dlg[56].flags&=~D_SELECTED;
6755
6756 large_dialog(gamepad_dlg);
6757
6758 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6759
6760 if(ret == 4) //OK
6761 {
6762 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6763 save_control_configs(false);
6764 }
6765 else //Cancel
6766 {
6767 Abtn = a;
6768 Bbtn = b;
6769 Sbtn = s;
6770 Lbtn = l;
6771 Rbtn = r;
6772 Mbtn = m;
6773 Pbtn = p;
6774 Exbtn1 = ex1;
6775 Exbtn2 = ex2;
6776 Exbtn3 = ex3;
6777 Exbtn4 = ex4;
6778 DUbtn = up;
6779 DDbtn = down;
6780 DLbtn = left;
6781 DRbtn = right;
6782 }
6783
6784 return D_O_K;
6785 }
6786
6787 int32_t onCheatKeys()
6788 {
6789 int32_t oldcheats[Cheat::Last][2];
6790 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6791
6792 bool done=false;
6793
6794 while(!done)
6795 {
6796 bool confirm = false;
6797 CheatKeysDialog(&confirm).show();
6798 if(confirm) // OK
6799 {
6800 std::vector<std::string> uniqueError;
6801 char buf[512];
6802 for(size_t q = 1; q < Cheat::Last; ++q)
6803 {
6804 if(cheatkeys[q][1] && !cheatkeys[q][0])
6805 {
6806 cheatkeys[q][0] = cheatkeys[q][1];
6807 cheatkeys[q][1] = 0;
6808 }
6809 }
6810 for(size_t q = 1; q < Cheat::Last; ++q)
6811 {
6812 if(!bindable_cheat((Cheat)q)) continue;
6813 for(size_t p = q+1; p < Cheat::Last; ++p)
6814 {
6815 if(!bindable_cheat((Cheat)p)) continue;
6816 for(size_t q2 = 0; q2 <= 1; ++q2)
6817 for(size_t p2 = 0; p2 <= 1; ++p2)
6818 {
6819 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6820 {
6821 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6822 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6823 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6824 get_keystr(cheatkeys[q][q2])));
6825 }
6826 }
6827 }
6828 }
6829 if(uniqueError.size() == 0)
6830 {
6831 done = true;
6832 save_cheatkeys();
6833 }
6834 else
6835 {
6836 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6837 box_out("Cannot have duplicate keybinds!"); box_eol();
6838 for(std::vector<std::string>::iterator it = uniqueError.begin();
6839 it != uniqueError.end(); ++it)
6840 {
6841 box_out((*it).c_str()); box_eol();
6842 }
6843 box_end(true);
6844 }
6845 }
6846 else // Cancel
6847 {
6848 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6849 done=true;
6850 }
6851 rest(1);
6852 }
6853
6854 return D_O_K;
6855 }
6856
6857 int32_t onSound()
6858 {
6859 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6860 {
6861 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6862 }
6863 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6864 {
6865 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6866 }
6867 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6868 {
6869 emusic_volume = (int32_t)FFCore.usr_music_volume;
6870 }
6871 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
6872 {
6873 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6874 }
6875 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6876 {
6877 pan_style = (int32_t)FFCore.usr_panstyle;
6878 }
6879
6880 int32_t m = midi_volume;
6881 int32_t d = digi_volume;
6882 int32_t e = emusic_volume;
6883 int32_t b = zcmusic_bufsz;
6884 int32_t s = sfx_volume;
6885 int32_t p = pan_style;
6886 pan_style = vbound(pan_style,0,3);
6887
6888 sound_dlg[0].dp2=get_zc_font(font_lfont);
6889
6890 large_dialog(sound_dlg);
6891
6892 midi_dp[1] = sound_dlg[6].x;
6893 midi_dp[2] = sound_dlg[6].y;
6894 digi_dp[1] = sound_dlg[7].x;
6895 digi_dp[2] = sound_dlg[7].y;
6896 emus_dp[1] = sound_dlg[8].x;
6897 emus_dp[2] = sound_dlg[8].y;
6898 buf_dp[1] = sound_dlg[9].x;
6899 buf_dp[2] = sound_dlg[9].y;
6900 sfx_dp[1] = sound_dlg[10].x;
6901 sfx_dp[2] = sound_dlg[10].y;
6902 pan_dp[1] = sound_dlg[11].x;
6903 pan_dp[2] = sound_dlg[11].y;
6904 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6905 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6906 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6907 sound_dlg[18].d2 = zcmusic_bufsz;
6908 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6909 sound_dlg[20].d2 = pan_style;
6910
6911 int32_t ret = zc_popup_dialog(sound_dlg,1);
6912
6913 if(ret==2)
6914 {
6915 master_volume(digi_volume,midi_volume);
6916
6917 for(int32_t i=0; i<WAV_COUNT; ++i)
6918 {
6919 //allegro assertion fails when passing in -1 as voice -DD
6920 if(sfx_voice[i] > 0)
6921 voice_set_volume(sfx_voice[i], sfx_volume);
6922 }
6923 zc_set_config(sfx_sect,"digi",digi_volume);
6924 zc_set_config(sfx_sect,"midi",midi_volume);
6925 zc_set_config(sfx_sect,"sfx",sfx_volume);
6926 zc_set_config(sfx_sect,"emusic",emusic_volume);
6927 zc_set_config(sfx_sect,"pan",pan_style);
6928 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6929 }
6930 else
6931 {
6932 midi_volume = m;
6933 digi_volume = d;
6934 emusic_volume = e;
6935 zcmusic_bufsz = b;
6936 sfx_volume = s;
6937 pan_style = p;
6938 }
6939
6940 return D_O_K;
6941 }
6942
6943 int32_t queding(char const* s1, char const* s2, char const* s3)
6944 {
6945 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6946 }
6947
6948 int32_t onQuit()
6949 {
6950 if(Playing)
6951 {
6952 int32_t ret=0;
6953
6954 if(get_bit(quest_rules, qr_NOCONTINUE))
6955 {
6956 if(standalone_mode)
6957 {
6958 ret=queding("End current game?",
6959 "The continue screen is disabled; the game",
6960 "will be reloaded from the last save.");
6961 }
6962 else
6963 {
6964 ret=queding("End current game?",
6965 "The continue screen is disabled. You will",
6966 "be returned to the file select screen.");
6967 }
6968 }
6969 else
6970 ret=queding("End current game?",NULL,NULL);
6971
6972 if(ret==1)
6973 {
6974 disableClickToFreeze=false;
6975 Quit=qQUIT;
6976
6977 // Trying to evade a door repair charge?
6978 if(repaircharge)
6979 {
6980 game->change_drupy(-repaircharge);
6981 repaircharge=0;
6982 }
6983
6984 return D_CLOSE;
6985 }
6986 }
6987
6988 return D_O_K;
6989 }
6990
6991 int32_t onTryQuitMenu()
6992 {
6993 return onTryQuit(true);
6994 }
6995
6996 int32_t onTryQuit(bool inMenu)
6997 {
6998 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
6999 {
7000 if(active_cutscene.can_f6())
7001 {
7002 if(get_bit(quest_rules,qr_OLD_F6))
7003 {
7004 if(inMenu) onQuit();
7005 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7006 }
7007 else
7008 {
7009 disableClickToFreeze=false;
7010 GameFlags |= GAMEFLAG_TRYQUIT;
7011 }
7012 return D_CLOSE;
7013 }
7014 else active_cutscene.error();
7015 }
7016
7017 return D_O_K;
7018 }
7019
7020 int32_t onReset()
7021 {
7022 if(queding(" Reset system? ",NULL,NULL)==1)
7023 {
7024 disableClickToFreeze=false;
7025 Quit=qRESET;
7026 replay_quit();
7027 return D_CLOSE;
7028 }
7029
7030 return D_O_K;
7031 }
7032
7033 int32_t onExit()
7034 {
7035 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7036 {
7037 Quit=qEXIT;
7038 return D_CLOSE;
7039 }
7040
7041 return D_O_K;
7042 }
7043
7044 int32_t onTitle_NES()
7045 {
7046 title_version=0;
7047 zc_set_config(cfg_sect,"title",title_version);
7048 return D_O_K;
7049 }
7050 int32_t onTitle_DX()
7051 {
7052 title_version=1;
7053 zc_set_config(cfg_sect,"title",title_version);
7054 return D_O_K;
7055 }
7056 int32_t onTitle_25()
7057 {
7058 title_version=2;
7059 zc_set_config(cfg_sect,"title",title_version);
7060 return D_O_K;
7061 }
7062
7063 int32_t onDebug()
7064 {
7065 if(debug_enabled)
7066 set_debug(!get_debug());
7067 return D_O_K;
7068 }
7069
7070 int32_t onHeartBeep()
7071 {
7072 heart_beep=!heart_beep;
7073 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7074 return D_O_K;
7075 }
7076
7077 int32_t onSaveIndicator()
7078 {
7079 use_save_indicator = use_save_indicator ? 0 : 1;
7080 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7081 return D_O_K;
7082 }
7083
7084 int32_t onEpilepsy()
7085 {
7086 if(jwin_alert3(
7087 "Epilepsy Flash Reduction",
7088 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7089 "Disabling this will restore standard flash and wavy behaviour.",
7090 "Proceed?",
7091 "&Yes",
7092 "&No",
7093 NULL,
7094 'y',
7095 'n',
7096 0,
7097 get_zc_font(font_lfont)) == 1)
7098 {
7099 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7100 zc_set_config("zeldadx","checked_epilepsy",1);
7101 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7102 }
7103 return D_O_K;
7104 }
7105
7106 int32_t onTriforce()
7107 {
7108 for(int32_t i=0; i<MAXINITTABS; ++i)
7109 {
7110 init_tabs[i].flags&=~D_SELECTED;
7111 }
7112
7113 init_tabs[3].flags=D_SELECTED;
7114 return onCheatConsole();
7115 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7116 for(int32_t i=1; i<=8; i++)
7117 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7118
7119 if(zc_popup_dialog (triforce_dlg,-1)==9)
7120 {
7121 for(int32_t i=1; i<=8; i++)
7122 {
7123 game->lvlitems[i] &= ~liTRIFORCE;
7124 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7125 }
7126 }
7127 return D_O_K;*/
7128 }
7129
7130 bool rc = false;
7131 /*
7132 int32_t onEquipment()
7133 {
7134 for (int32_t i=0; i<MAXINITTABS; ++i)
7135 {
7136 init_tabs[i].flags&=~D_SELECTED;
7137 }
7138 init_tabs[0].flags=D_SELECTED;
7139 return onCheatConsole();
7140 }
7141 */
7142
7143 int32_t onItems()
7144 {
7145 for(int32_t i=0; i<MAXINITTABS; ++i)
7146 {
7147 init_tabs[i].flags&=~D_SELECTED;
7148 }
7149
7150 init_tabs[1].flags=D_SELECTED;
7151 return onCheatConsole();
7152 }
7153
7154 static DIALOG getnum_dlg[] =
7155 {
7156 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7157 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7158 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7159 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7160 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7161 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7162 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7163 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7164 };
7165
7166 int32_t getnumber(const char *prompt,int32_t initialval)
7167 {
7168 char buf[20];
7169 sprintf(buf,"%d",initialval);
7170 getnum_dlg[0].dp=(void *)prompt;
7171 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7172 getnum_dlg[2].dp=buf;
7173
7174 large_dialog(getnum_dlg);
7175
7176 if(zc_popup_dialog(getnum_dlg,2)==3)
7177 return atoi(buf);
7178
7179 return initialval;
7180 }
7181
7182 int32_t onLife()
7183 {
7184 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7185 cheats_enqueue(Cheat::Life, value);
7186 return D_O_K;
7187 }
7188
7189 int32_t onHeartC()
7190 {
7191 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7192 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7193 cheats_enqueue(Cheat::MaxLife, max_life);
7194 cheats_enqueue(Cheat::Life, life);
7195 return D_O_K;
7196 }
7197
7198 int32_t onMagicC()
7199 {
7200 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7201 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7202 cheats_enqueue(Cheat::MaxMagic, max_magic);
7203 cheats_enqueue(Cheat::Magic, magic);
7204 return D_O_K;
7205 }
7206
7207 int32_t onRupies()
7208 {
7209 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7210 cheats_enqueue(Cheat::Rupies, value);
7211 return D_O_K;
7212 }
7213
7214 int32_t onMaxBombs()
7215 {
7216 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7217 cheats_enqueue(Cheat::MaxBombs, value);
7218 cheats_enqueue(Cheat::Bombs, value);
7219 return D_O_K;
7220 }
7221
7222 int32_t onRefillLife()
7223 {
7224 cheats_enqueue(Cheat::Life, game->get_maxlife());
7225 return D_O_K;
7226 }
7227 int32_t onRefillMagic()
7228 {
7229 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7230 return D_O_K;
7231 }
7232 int32_t onClock()
7233 {
7234 cheats_enqueue(Cheat::Clock);
7235 return D_O_K;
7236 }
7237
7238 int32_t onQstPath()
7239 {
7240 char path[2048];
7241
7242 chop_path(qstdir);
7243 strcpy(path,qstdir);
7244
7245 go();
7246
7247 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7248 {
7249 chop_path(path);
7250 fix_filename_case(path);
7251 fix_filename_slashes(path);
7252 strcpy(qstdir,path);
7253 strcpy(qstpath,qstdir);
7254 }
7255
7256 comeback();
7257 return D_O_K;
7258 }
7259
7260 #include "dialog/cheat_dialog.h"
7261 int32_t onCheat()
7262 {
7263 call_setcheat_dialog();
7264 game->set_cheat(maxcheat);
7265 if(cheat) game->did_cheat(true);
7266 return D_O_K;
7267 }
7268
7269 int32_t onCheatRupies()
7270 {
7271 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7272 return D_O_K;
7273 }
7274
7275 int32_t onCheatArrows()
7276 {
7277 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7278 return D_O_K;
7279 }
7280
7281 int32_t onCheatBombs()
7282 {
7283 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7284 return D_O_K;
7285 }
7286
7287 // *** screen saver
7288
7289 8135902 int32_t after_time()
7290 {
7291
1/2
✓ Branch 0 taken 8135902 times.
✗ Branch 1 not taken.
8135902 if(ss_enable == 0)
7292 return INT_MAX;
7293
7294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8135902 times.
8135902 if(ss_after <= 0)
7295 return 5 * 60;
7296
7297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8135902 times.
8135902 if(ss_after <= 3)
7298 return ss_after * 15 * 60;
7299
7300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8135902 times.
8135902 if(ss_after <= 13)
7301 return (ss_after - 3) * 60 * 60;
7302
7303 8135902 return MAX_IDLE + 1;
7304 8135902 }
7305
7306 static const char *after_str[15] =
7307 {
7308 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7309 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7310 "Never"
7311 };
7312
7313 const char *after_list(int32_t index, int32_t *list_size)
7314 {
7315 if(index < 0)
7316 {
7317 *list_size = 15;
7318 return NULL;
7319 }
7320
7321 return after_str[index];
7322 }
7323
7324 34 static ListData after__list(after_list, &font);
7325
7326 static DIALOG scrsaver_dlg[] =
7327 {
7328 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7329 34 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7330 34 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7331 34 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7332 34 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7333 34 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7334 34 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7335 34 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7336 34 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7337 34 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7338 34 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7339 34 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7340 34 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7341 34 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7342 };
7343
7344 int32_t onScreenSaver()
7345 {
7346 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7347 int32_t oldcfgs[3];
7348 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7349 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7350 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7351
7352 large_dialog(scrsaver_dlg);
7353
7354 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7355
7356 if(ret == 8 || ret == 9)
7357 {
7358 ss_after = scrsaver_dlg[5].d1;
7359 ss_speed = scrsaver_dlg[6].d2;
7360 ss_density = scrsaver_dlg[7].d2;
7361 if(oldcfgs[0] != ss_after)
7362 zc_set_config(cfg_sect,"ss_after",ss_after);
7363 if(oldcfgs[1] != ss_speed)
7364 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7365 if(oldcfgs[2] != ss_density)
7366 zc_set_config(cfg_sect,"ss_density",ss_density);
7367 }
7368
7369 if(ret == 9)
7370 // preview Screen Saver
7371 {
7372 clear_keybuf();
7373 Matrix(ss_speed, ss_density, 30);
7374 system_pal();
7375 sys_mouse();
7376 }
7377
7378 return D_O_K;
7379 }
7380
7381 /***** Menus *****/
7382
7383 static MENU game_menu[] =
7384 {
7385 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7386 { (char *)"", NULL, NULL, 0, NULL },
7387 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7388 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7389 { (char *)"", NULL, NULL, 0, NULL },
7390 #ifdef __EMSCRIPTEN__
7391 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7392 #elif defined(ALLEGRO_MACOSX)
7393 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7394 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7395 #else
7396 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7397 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7398 #endif
7399 { NULL, NULL, NULL, 0, NULL }
7400 };
7401
7402 static MENU title_menu[] =
7403 {
7404 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7405 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7406 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7407 { NULL, NULL, NULL, 0, NULL }
7408 };
7409
7410 static MENU snapshot_format_menu[] =
7411 {
7412 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7413 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7414 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7415 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7416 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7417 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7418 { NULL, NULL, NULL, 0, NULL }
7419 };
7420
7421 static MENU controls_menu[] =
7422 {
7423 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7424 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7425 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7426 { NULL, NULL, NULL, 0, NULL }
7427 };
7428
7429 static MENU name_entry_mode_menu[] =
7430 {
7431 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7432 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7433 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7434 { NULL, NULL, NULL, 0, NULL }
7435 };
7436
7437 static void set_controls_menu_active()
7438 {
7439
7440 }
7441
7442 static MENU window_menu[] =
7443 {
7444 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7445 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7446 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7447 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7448 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7449 { NULL, NULL, NULL, 0, NULL }
7450 };
7451 static MENU options_menu[] =
7452 {
7453 { "&Title Screen", NULL, title_menu, 0, NULL },
7454 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7455 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7456 { "&Window Settings", NULL, window_menu, 0, NULL },
7457 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7458 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7459 { NULL, NULL, NULL, 0, NULL }
7460 };
7461 static MENU settings_menu[] =
7462 {
7463 { "&Sound...", onSound, NULL, 0, NULL },
7464 { "C&ontrols", NULL, controls_menu, 0, NULL },
7465 { "", NULL, NULL, 0, NULL },
7466 { "Options", NULL, options_menu, 0, NULL },
7467 { "", NULL, NULL, 0, NULL },
7468 //
7469 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7470 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7471 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7472 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7473 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7474 //
7475 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7476 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7477 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7478 { "", NULL, NULL, 0, NULL },
7479 { "Debu&g", onDebug, NULL, 0, NULL },
7480 //
7481 { NULL, NULL, NULL, 0, NULL }
7482 };
7483
7484
7485 static MENU misc_menu[] =
7486 {
7487 { (char *)"&About...", onAbout, NULL, 0, NULL },
7488 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7489 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7490 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7491 { (char *)"", NULL, NULL, 0, NULL },
7492 //5
7493 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7494 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7495 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7496 { (char *)"", NULL, NULL, 0, NULL },
7497 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7498 //10
7499 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7500 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7501 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7502 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7503 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7504 //15
7505 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7506 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7507 { NULL, NULL, NULL, 0, NULL }
7508 };
7509
7510 static MENU refill_menu[] =
7511 {
7512 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7513 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7514 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7515 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7516 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7517 { NULL, NULL, NULL, 0, NULL }
7518 };
7519
7520 static MENU show_menu[] =
7521 {
7522 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7523 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7524 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7525 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7526 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7527 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7528 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7529 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7530 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7531 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7532 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7533 { (char *)"", NULL, NULL, 0, NULL },
7534 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7535 { (char *)"", NULL, NULL, 0, NULL },
7536 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7537 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7538 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7539 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7540 { NULL, NULL, NULL, 0, NULL }
7541 };
7542
7543 static MENU cheat_menu[] =
7544 {
7545 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7546 { (char *)"", NULL, NULL, 0, NULL },
7547 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7548 { (char *)"", NULL, NULL, 0, NULL },
7549 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7550 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7551 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7552 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7553 { (char *)"", NULL, NULL, 0, NULL },
7554 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7555 { (char *)"", NULL, NULL, 0, NULL },
7556 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7557 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7558 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7559 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7560 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7561 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7562 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7563 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7564 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7565 { NULL, NULL, NULL, 0, NULL }
7566 };
7567
7568 #if DEVLEVEL > 0
7569 int32_t devLogging();
7570 int32_t devDebug();
7571 int32_t devTimestmp();
7572 #if DEVLEVEL > 1
7573 int32_t setCheat();
7574 #endif //DEVLEVEL > 1
7575 enum
7576 {
7577 dv_log,
7578 // dv_dbg,
7579 dv_tmpstmp,
7580 #if DEVLEVEL > 1
7581 dv_nil,
7582 dv_setcheat,
7583 #endif //DEVLEVEL > 1
7584 dv_max
7585 };
7586 static MENU dev_menu[] =
7587 {
7588 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7589 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7590 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7591 #if DEVLEVEL > 1
7592 { (char *)"", NULL, NULL, 0, NULL },
7593 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7594 #endif //DEVLEVEL > 1
7595 { NULL, NULL, NULL, 0, NULL }
7596 };
7597 int32_t devLogging()
7598 {
7599 dev_logging = !dev_logging;
7600 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7601 return D_O_K;
7602 }
7603 // int32_t devDebug()
7604 // {
7605 // dev_debug = !dev_debug;
7606 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7607 // return D_O_K;
7608 // }
7609 int32_t devTimestmp()
7610 {
7611 dev_timestmp = !dev_timestmp;
7612 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7613 return D_O_K;
7614 }
7615 #if DEVLEVEL > 1
7616 int32_t setCheat()
7617 {
7618 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7619 return D_O_K;
7620 }
7621 #endif //DEVLEVEL > 1
7622 #endif //DEVLEVEL > 0
7623
7624 MENU the_player_menu[] =
7625 {
7626 { (char *)"&Game", NULL, game_menu, 0, NULL },
7627 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7628 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7629 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7630 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7631 #if DEVLEVEL > 0
7632 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7633 #endif
7634 { NULL, NULL, NULL, 0, NULL }
7635 };
7636 int32_t onMIDIPatch()
7637 {
7638 if(jwin_alert3(
7639 "Toggle Windows MIDI Fix",
7640 "This action will change whether ZC Player auto-restarts a MIDI at its",
7641 "last index if you move ZC Player out of focus, then back into focus.",
7642 "Proceed?",
7643 "&Yes",
7644 "&No",
7645 NULL,
7646 'y',
7647 'n',
7648 0,
7649 get_zc_font(font_lfont)) == 1)
7650 {
7651 midi_patch_fix = midi_patch_fix ? 0 : 1;
7652 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7653 }
7654 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7655 return D_O_K;
7656 }
7657
7658 int32_t onKeyboardEntry()
7659 {
7660 NameEntryMode=0;
7661 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7662 return D_O_K;
7663 }
7664
7665 int32_t onLetterGridEntry()
7666 {
7667 NameEntryMode=1;
7668 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7669 return D_O_K;
7670 }
7671
7672 int32_t onExtLetterGridEntry()
7673 {
7674 NameEntryMode=2;
7675 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7676 return D_O_K;
7677 }
7678
7679 static BITMAP* oldscreen;
7680 int32_t onFullscreenMenu()
7681 {
7682 // super hacks
7683 screen = oldscreen;
7684 if (onFullscreen() == D_REDRAW)
7685 {
7686 oldscreen = screen;
7687 }
7688 screen = menu_bmp;
7689 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7690 return D_O_K;
7691 }
7692
7693 34 void fix_menu()
7694 {
7695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(!debug_enabled)
7696 34 settings_menu[13].text = NULL;
7697 34 }
7698
7699 static DIALOG system_dlg[] =
7700 {
7701 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7702 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7703 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7704 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7705 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7706 #ifndef ALLEGRO_MACOSX
7707 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7708 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7709 #else
7710 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7711 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7712 #endif
7713 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7714 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7715 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7716 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7717 };
7718
7719 void reset_snapshot_format_menu()
7720 {
7721 for(int32_t i=0; i<ssfmtMAX; ++i)
7722 {
7723 snapshot_format_menu[i].flags=0;
7724 }
7725 }
7726
7727 int32_t onSetSnapshotFormat()
7728 {
7729 switch(active_menu->text[1])
7730 {
7731 case 'B': //"&BMP"
7732 SnapshotFormat=0;
7733 break;
7734
7735 case 'G': //"&GIF"
7736 SnapshotFormat=1;
7737 break;
7738
7739 case 'J': //"&JPG"
7740 SnapshotFormat=2;
7741 break;
7742
7743 case 'P': //"&PNG"
7744 SnapshotFormat=3;
7745 break;
7746
7747 case 'C': //"PC&X"
7748 SnapshotFormat=4;
7749 break;
7750
7751 case 'T': //"&TGA"
7752 SnapshotFormat=5;
7753 break;
7754
7755 case 'L': //"&LBM"
7756 SnapshotFormat=6;
7757 break;
7758 }
7759 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7760
7761 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7762 return D_O_K;
7763 }
7764
7765
7766 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7767 {
7768 PALETTE tmp;
7769
7770 for(int32_t i=0; i<256; i++)
7771 {
7772 tmp[i].r=r;
7773 tmp[i].g=g;
7774 tmp[i].b=b;
7775 }
7776
7777 fade_interpolate(src,tmp,dest,pos,from,to);
7778 }
7779
7780 48 void system_pal(bool force)
7781 {
7782
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(is_sys_pal && !force) return;
7783 48 is_sys_pal = true;
7784 48 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7785 48 hw_palette = &syspal;
7786 48 update_hw_pal = true;
7787 48 }
7788
7789 static uint32_t entered_sys_pal = 0;
7790 48 void enter_sys_pal()
7791 {
7792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(is_sys_pal)
7793 {
7794 if(entered_sys_pal)
7795 ++entered_sys_pal;
7796 return;
7797 }
7798 48 sys_mouse();
7799 48 system_pal(true);
7800 48 ++entered_sys_pal;
7801 48 }
7802 48 void exit_sys_pal()
7803 {
7804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(entered_sys_pal)
7805 {
7806
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!--entered_sys_pal)
7807 {
7808 48 game_pal();
7809 48 game_mouse();
7810 48 }
7811 48 }
7812 48 }
7813
7814 void switch_out_callback()
7815 {
7816 if (pause_in_background)
7817 {
7818 callback_switchin = 3;
7819 return;
7820 }
7821
7822 #ifdef _WIN32
7823 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
7824 return;
7825
7826
7827 paused_midi_pos = midi_pos;
7828 zc_stop_midi();
7829 midi_paused=true;
7830 midi_suspended = midissuspHALTED;
7831 #endif
7832 }
7833
7834 void switch_in_callback()
7835 {
7836 if(pause_in_background)
7837 {
7838 return;
7839 }
7840
7841 #ifdef _WIN32
7842 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
7843 return;
7844
7845 else
7846 {
7847 callback_switchin = 1;
7848 midi_suspended = midissuspRESUME;
7849 }
7850 #endif
7851 }
7852
7853 344 void game_pal()
7854 {
7855 344 is_sys_pal = false;
7856 344 entered_sys_pal = 0;
7857 344 hw_palette = &RAMpal;
7858 344 update_hw_pal = true;
7859 344 }
7860
7861 static char bar_str[] = "";
7862
7863 14 void music_pause()
7864 {
7865 //al_pause_duh(tmplayer);
7866 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
7867 14 zc_midi_pause();
7868 14 midi_paused=true;
7869 14 }
7870
7871 void music_resume()
7872 {
7873 //al_resume_duh(tmplayer);
7874 zcmusic_pause(zcmusic, ZCM_RESUME);
7875 zc_midi_resume();
7876 midi_paused=false;
7877 }
7878
7879 6590 void music_stop()
7880 {
7881 //al_stop_duh(tmplayer);
7882 //unload_duh(tmusic);
7883 //tmusic=NULL;
7884 //tmplayer=NULL;
7885 6590 zcmusic_stop(zcmusic);
7886 6590 zcmusic_unload_file(zcmusic);
7887 6590 zc_stop_midi();
7888 6590 midi_paused=false;
7889 6590 currmidi=-1;
7890 6590 }
7891
7892 void System()
7893 {
7894 mouse_down=gui_mouse_b();
7895 music_pause();
7896 pause_all_sfx();
7897 MenuOpen = true;
7898 enter_sys_pal();
7899 // FONT *oldfont=font;
7900 // font=tfont;
7901
7902 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7903 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7904
7905 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7906 #if DEVLEVEL > 1
7907 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7908 #endif
7909 game_menu[3].flags =
7910 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7911 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7912 clear_keybuf();
7913
7914 DIALOG_PLAYER *p;
7915
7916 clear_bitmap(menu_bmp);
7917 oldscreen = screen;
7918 screen = menu_bmp;
7919
7920 p = init_dialog(system_dlg,-1);
7921
7922 // drop the menu on startup if menu button pressed
7923 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7924 simulate_keypress(KEY_G << 8);
7925
7926 do
7927 {
7928 if(close_button_quit)
7929 {
7930 close_button_quit = false;
7931 f_Quit(qEXIT);
7932 if(Quit) break;
7933 }
7934 rest(17);
7935
7936 if(mouse_down && !gui_mouse_b())
7937 mouse_down=0;
7938
7939 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
7940 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
7941 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
7942
7943 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7944 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7945 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7946 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7947 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7948 settings_menu[10].flags = NESquit?D_SELECTED:0;
7949 settings_menu[11].flags = volkeys?D_SELECTED:0;
7950
7951 window_menu[0].flags = DragAspect?D_SELECTED:0;
7952 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7953 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7954 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7955 window_menu[4].flags = stretchGame?D_SELECTED:0;
7956
7957 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7958 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
7959
7960 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7961 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7962 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7963
7964 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7965 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7966 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7967
7968 bool nocheat = (replay_is_replaying() || !Playing
7969 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7970 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7971 cheat_menu[0].flags = 0;
7972 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
7973 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7974 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7975 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7976 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7977 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7978 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7979 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7980 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7981
7982 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7983 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7984 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7985 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7986 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7987 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7988 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7989 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7990 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7991 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7992 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7993 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7994 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7995 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7996 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7997
7998 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7999 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8000
8001 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8002 (char *)"Disable recording new saves" :
8003 (char *)"Enable recording new saves";
8004 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8005 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8006 (char *)"Stop recording" :
8007 (char *)"Stop replaying";
8008 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8009 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8010 (char *)"Disable snapshot all frames" :
8011 (char *)"Enable snapshot all frames";
8012
8013 reset_snapshot_format_menu();
8014 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8015
8016 if(debug_enabled)
8017 {
8018 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8019 }
8020
8021 if(gui_mouse_b() && !mouse_down)
8022 break;
8023
8024 // press menu to drop the menu
8025 if(rMbtn())
8026 simulate_keypress(KEY_G << 8);
8027
8028 if(input_idle(true) > after_time())
8029 // run Screeen Saver
8030 {
8031 // Screen saver enabled for now.
8032 clear_keybuf();
8033 Matrix(ss_speed, ss_density, 0);
8034 system_pal();
8035 sys_mouse();
8036 broadcast_dialog_message(MSG_DRAW, 0);
8037 }
8038
8039 update_hw_screen();
8040 }
8041 while(update_dialog(p));
8042
8043 screen = oldscreen;
8044
8045 // font=oldfont;
8046 mouse_down=gui_mouse_b();
8047 shutdown_dialog(p);
8048 MenuOpen = false;
8049 if(Quit)
8050 {
8051 kill_sfx();
8052 music_stop();
8053 update_hw_screen();
8054 }
8055 else
8056 {
8057 music_resume();
8058 resume_all_sfx();
8059
8060 if(rc)
8061 ringcolor(false);
8062 }
8063 exit_sys_pal();
8064
8065 eat_buttons();
8066
8067 rc=false;
8068 clear_keybuf();
8069 // text_mode(0);
8070 }
8071
8072 34 void fix_dialogs()
8073 {
8074 34 jwin_center_dialog(about_dlg);
8075 34 jwin_center_dialog(gamepad_dlg);
8076 34 jwin_center_dialog(credits_dlg);
8077 34 jwin_center_dialog(gamemode_dlg);
8078 34 jwin_center_dialog(getnum_dlg);
8079 34 jwin_center_dialog(goto_dlg);
8080 34 jwin_center_dialog(keyboard_control_dlg);
8081 34 jwin_center_dialog(midi_dlg);
8082 34 jwin_center_dialog(quest_dlg);
8083 34 jwin_center_dialog(scrsaver_dlg);
8084 34 jwin_center_dialog(sound_dlg);
8085 34 jwin_center_dialog(triforce_dlg);
8086
8087 // digi_dp[1] += scrx;
8088 // digi_dp[2] += scry;
8089 // midi_dp[1] += scrx;
8090 // midi_dp[2] += scry;
8091 // pan_dp[1] += scrx;
8092 // pan_dp[2] += scry;
8093 // emus_dp[1] += scrx;
8094 // emus_dp[2] += scry;
8095 // buf_dp[1] += scrx;
8096 // buf_dp[2] += scry;
8097 // sfx_dp[1] += scrx;
8098 // sfx_dp[2] += scry;
8099 34 }
8100
8101 /*****************************/
8102 /**** Custom Sound System ****/
8103 /*****************************/
8104
8105 2894 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8106 {
8107
3/4
✓ Branch 0 taken 2636 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 2894 times.
✗ Branch 3 not taken.
2894 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8108 }
8109
8110 // Run an NSF, or a MIDI if the NSF is missing somehow.
8111 106 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8112 {
8113 106 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8114
8115 // Found it
8116
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 38 times.
106 if(newzcmusic!=NULL)
8117 {
8118 68 zcmusic_stop(zcmusic);
8119 68 zcmusic_unload_file(zcmusic);
8120 68 zc_stop_midi();
8121
8122 68 zcmusic=newzcmusic;
8123 68 zcmusic_play(zcmusic, emusic_volume);
8124
8125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(track>0)
8126 68 zcmusic_change_track(zcmusic,track);
8127
8128 68 return true;
8129 }
8130
8131 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8132
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 else if(midi>-1000)
8133 jukebox(midi);
8134
8135 38 return false;
8136 106 }
8137
8138 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8139 {
8140 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8141 // Found it
8142 if(newzcmusic!=NULL)
8143 {
8144 zcmusic_stop(zcmusic);
8145 zcmusic_unload_file(zcmusic);
8146 zc_stop_midi();
8147
8148 zcmusic=newzcmusic;
8149 zcmusic_play(zcmusic, emusic_volume);
8150
8151 if(track>0)
8152 zcmusic_change_track(zcmusic,track);
8153
8154 return true;
8155 }
8156
8157 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8158 else if(midi>-1000)
8159 jukebox(midi);
8160
8161 return false;
8162 }
8163
8164 int32_t get_zcmusicpos()
8165 {
8166 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8167 return debugtracething;
8168 return 0;
8169 }
8170
8171 void set_zcmusicpos(int32_t position)
8172 {
8173 zcmusic_set_curpos(zcmusic, position);
8174 }
8175
8176 void set_zcmusicspeed(int32_t speed)
8177 {
8178 int32_t newspeed = vbound(speed, 0, 10000);
8179 zcmusic_set_speed(zcmusic, newspeed);
8180 }
8181
8182 1430 void jukebox(int32_t index,int32_t loop)
8183 {
8184 1430 music_stop();
8185
8186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(index<0) index=MAXMIDIS-1;
8187
8188
1/2
✓ Branch 0 taken 1430 times.
✗ Branch 1 not taken.
1430 if(index>=MAXMIDIS) index=0;
8189
8190 1430 music_stop();
8191
8192 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8193 // stuck notes when a song stops. This fixes it.
8194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(strcmp(midi_driver->name, "DIGMID")==0)
8195 zc_set_volume(0, 0);
8196
8197 1430 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8198 1430 zc_play_midi((MIDI*)tunes[index].data,loop);
8199
8200
2/2
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 402 times.
1430 if(tunes[index].start>0)
8201 402 zc_midi_seek(tunes[index].start);
8202
8203 1430 midi_loop_start = tunes[index].loop_start;
8204 1430 midi_loop_end = tunes[index].loop_end;
8205
8206 1430 currmidi=index;
8207 1430 master_volume(digi_volume,midi_volume);
8208 1430 midi_paused=false;
8209 1430 }
8210
8211 11423 void jukebox(int32_t index)
8212 {
8213
1/2
✓ Branch 0 taken 11423 times.
✗ Branch 1 not taken.
11423 if(index<0) index=MAXMIDIS-1;
8214
8215
1/2
✓ Branch 0 taken 11423 times.
✗ Branch 1 not taken.
11423 if(index>=MAXMIDIS) index=0;
8216
8217 // do nothing if it's already playing
8218
3/4
✓ Branch 0 taken 9993 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 9993 times.
✗ Branch 3 not taken.
11423 if(index==currmidi && midi_pos>=0)
8219 {
8220 9993 midi_paused=false;
8221 9993 return;
8222 }
8223
8224 1430 jukebox(index,tunes[index].loop);
8225 11423 }
8226
8227 12754 void play_DmapMusic()
8228 {
8229 static char tfile[2048];
8230 static int32_t ttrack=0;
8231 12754 bool domidi=false;
8232
8233
2/2
✓ Branch 0 taken 1455 times.
✓ Branch 1 taken 11299 times.
12754 if(DMaps[currdmap].tmusic[0]!=0)
8234 {
8235
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1070 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1840 if(zcmusic==NULL ||
8236
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8237
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8238 {
8239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1070 times.
1070 if(zcmusic != NULL)
8240 {
8241 zcmusic_stop(zcmusic);
8242 zcmusic_unload_file(zcmusic);
8243 zcmusic = NULL;
8244 }
8245
8246 1070 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8247
8248
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 983 times.
1070 if(zcmusic!=NULL)
8249 {
8250 87 zc_stop_midi();
8251 87 strcpy(tfile,DMaps[currdmap].tmusic);
8252 87 zcmusic_play(zcmusic, emusic_volume);
8253 87 int32_t temptracks=0;
8254 87 temptracks=zcmusic_get_tracks(zcmusic);
8255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 temptracks=(temptracks<2)?1:temptracks;
8256 87 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8257 87 zcmusic_change_track(zcmusic,ttrack);
8258 87 }
8259 else
8260 {
8261 983 tfile[0] = 0;
8262 983 domidi=true;
8263 }
8264 1070 }
8265 1455 }
8266 else
8267 {
8268 11299 domidi=true;
8269 }
8270
8271
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 12282 times.
12754 if(domidi)
8272 {
8273 12282 int32_t m=DMaps[currdmap].midi;
8274
8275
3/4
✓ Branch 0 taken 11875 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
12282 switch(m)
8276 {
8277 case 1:
8278 368 jukebox(ZC_MIDI_OVERWORLD);
8279 368 break;
8280
8281 case 2:
8282 39 jukebox(ZC_MIDI_DUNGEON);
8283 39 break;
8284
8285 case 3:
8286 jukebox(ZC_MIDI_LEVEL9);
8287 break;
8288
8289 default:
8290
3/4
✓ Branch 0 taken 10843 times.
✓ Branch 1 taken 1032 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10843 times.
11875 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8291 10843 jukebox(m+MIDIOFFSET_DMAP);
8292 else
8293 1032 music_stop();
8294 11875 }
8295 12282 }
8296 12754 }
8297
8298 12792 void playLevelMusic()
8299 {
8300 12792 int32_t m=tmpscr->screen_midi;
8301
8302
3/6
✓ Branch 0 taken 12738 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
12792 switch(m)
8303 {
8304 case -2:
8305 13 music_stop();
8306 13 break;
8307
8308 case -1:
8309 12738 play_DmapMusic();
8310 12738 break;
8311
8312 case 1:
8313 jukebox(ZC_MIDI_OVERWORLD);
8314 break;
8315
8316 case 2:
8317 jukebox(ZC_MIDI_DUNGEON);
8318 break;
8319
8320 case 3:
8321 jukebox(ZC_MIDI_LEVEL9);
8322 break;
8323
8324 default:
8325
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8326 41 jukebox(m+MIDIOFFSET_MAPSCR);
8327 else
8328 music_stop();
8329 41 }
8330 12792 }
8331
8332 1464 void master_volume(int32_t dv,int32_t mv)
8333 {
8334
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1464 times.
✓ Branch 2 taken 1464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1464 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1464 times.
✗ Branch 7 not taken.
1464 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8335
8336
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1464 times.
✓ Branch 2 taken 1464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1464 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1464 times.
✗ Branch 7 not taken.
1464 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8337
8338
6/6
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 1462 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1423 times.
✓ Branch 5 taken 39 times.
1464 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8339 1464 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8340 1464 }
8341
8342 /*****************/
8343 /***** SFX *****/
8344 /*****************/
8345
8346 // array of voices, one for each sfx sample in the data file
8347 // 0+ = voice #
8348 // -1 = voice not allocated
8349 34 void Z_init_sound()
8350 {
8351
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 34 times.
8738 for(int32_t i=0; i<WAV_COUNT; i++)
8352 8704 sfx_voice[i]=-1;
8353
8354
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 34 times.
272 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8355 238 tunes[i].data = (MIDI*)mididata[i].dat;
8356
8357
2/2
✓ Branch 0 taken 8568 times.
✓ Branch 1 taken 34 times.
8602 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8358 8568 tunes[ZC_MIDI_COUNT+j].data=NULL;
8359
8360 34 master_volume(digi_volume,midi_volume);
8361 34 }
8362
8363 // returns number of voices currently allocated
8364 int32_t sfx_count()
8365 {
8366 int32_t c=0;
8367
8368 for(int32_t i=0; i<WAV_COUNT; i++)
8369 if(sfx_voice[i]!=-1)
8370 ++c;
8371
8372 return c;
8373 }
8374
8375 // clean up finished samples
8376 8089220 void sfx_cleanup()
8377 {
8378
2/2
✓ Branch 0 taken 2070840320 times.
✓ Branch 1 taken 8089220 times.
2078929540 for(int32_t i=0; i<WAV_COUNT; i++)
8379
3/4
✓ Branch 0 taken 634453 times.
✓ Branch 1 taken 2070205867 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 634453 times.
2071474773 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8380 {
8381 634453 deallocate_voice(sfx_voice[i]);
8382 634453 sfx_voice[i]=-1;
8383 634453 }
8384 8089220 }
8385
8386 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8387 // if a voice is already allocated (and/or playing), then it just returns true
8388 // Returns true: voice is allocated
8389 // false: unsuccessful
8390 974660 bool sfx_init(int32_t index)
8391 {
8392 // check index
8393
3/4
✓ Branch 0 taken 703374 times.
✓ Branch 1 taken 271286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 703374 times.
974660 if(index<=0 || index>=WAV_COUNT)
8394 271286 return false;
8395
8396
2/2
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 634480 times.
703374 if(sfx_voice[index]==-1)
8397 {
8398
2/2
✓ Branch 0 taken 182177 times.
✓ Branch 1 taken 452303 times.
634480 if(sfxdat)
8399 {
8400
1/2
✓ Branch 0 taken 182177 times.
✗ Branch 1 not taken.
182177 if(index<Z35)
8401 {
8402 182177 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8403 182177 }
8404 else
8405 {
8406 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8407 }
8408 182177 }
8409 else
8410 {
8411 452303 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8412 }
8413
8414 634480 voice_set_volume(sfx_voice[index], sfx_volume);
8415 634480 }
8416
8417 703374 return sfx_voice[index] != -1;
8418 974660 }
8419
8420 // plays an sfx sample
8421 829480 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8422 {
8423
2/2
✓ Branch 0 taken 630969 times.
✓ Branch 1 taken 198511 times.
829480 if(!sfx_init(index))
8424 198511 return;
8425
8426 630969 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8427 630969 voice_set_pan(sfx_voice[index],pan);
8428
8429 630969 int32_t pos = voice_get_position(sfx_voice[index]);
8430
8431
2/2
✓ Branch 0 taken 298046 times.
✓ Branch 1 taken 332923 times.
630969 if(restart) voice_set_position(sfx_voice[index],0);
8432
8433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630969 times.
630969 if(pos<=0)
8434 630969 voice_start(sfx_voice[index]);
8435
8436
3/4
✓ Branch 0 taken 332923 times.
✓ Branch 1 taken 298046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 332923 times.
630969 if (restart && replay_is_debug())
8437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332923 times.
332923 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8438 829480 }
8439
8440 // true if sfx is allocated
8441 35405 bool sfx_allocated(int32_t index)
8442 {
8443
3/4
✓ Branch 0 taken 9407 times.
✓ Branch 1 taken 25998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9407 times.
35405 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8444 }
8445
8446 // start it (in loop mode) if it's not already playing,
8447 // otherwise adjust it to play in loop mode -DD
8448 145180 void cont_sfx(int32_t index)
8449 {
8450
2/2
✓ Branch 0 taken 72775 times.
✓ Branch 1 taken 72405 times.
145180 if(!sfx_init(index))
8451 {
8452 72775 return;
8453 }
8454
8455
1/2
✓ Branch 0 taken 72405 times.
✗ Branch 1 not taken.
72405 if(voice_get_position(sfx_voice[index])<=0)
8456 {
8457 72405 voice_set_position(sfx_voice[index],0);
8458 72405 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8459 72405 voice_start(sfx_voice[index]);
8460 72405 }
8461 else
8462 {
8463 adjust_sfx(index, 128, true);
8464 }
8465 145180 }
8466
8467 // adjust parameters while playing
8468 3961 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8469 {
8470
5/6
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2187 times.
3961 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8471 3947 return;
8472
8473 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8474 14 voice_set_pan(sfx_voice[index],pan);
8475 3961 }
8476
8477 // pauses a voice
8478 1651 void pause_sfx(int32_t index)
8479 {
8480
3/6
✓ Branch 0 taken 1651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1651 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1651 times.
1651 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8481 voice_stop(sfx_voice[index]);
8482 1651 }
8483
8484 // resumes a voice
8485 709 void resume_sfx(int32_t index)
8486 {
8487
3/6
✓ Branch 0 taken 709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 709 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 709 times.
709 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8488 voice_start(sfx_voice[index]);
8489 709 }
8490
8491 // pauses all active voices
8492 320 void pause_all_sfx()
8493 {
8494
2/2
✓ Branch 0 taken 81920 times.
✓ Branch 1 taken 320 times.
82240 for(int32_t i=0; i<WAV_COUNT; i++)
8495
2/2
✓ Branch 0 taken 81919 times.
✓ Branch 1 taken 1 times.
81921 if(sfx_voice[i]!=-1)
8496 1 voice_stop(sfx_voice[i]);
8497 320 }
8498
8499 // resumes all paused voices
8500 306 void resume_all_sfx()
8501 {
8502
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 306 times.
78642 for(int32_t i=0; i<WAV_COUNT; i++)
8503
1/2
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
78336 if(sfx_voice[i]!=-1)
8504 voice_start(sfx_voice[i]);
8505 306 }
8506
8507 // stops an sfx and deallocates the voice
8508 6473471 void stop_sfx(int32_t index)
8509 {
8510
3/4
✓ Branch 0 taken 5332270 times.
✓ Branch 1 taken 1141201 times.
✓ Branch 2 taken 5332270 times.
✗ Branch 3 not taken.
6473471 if(index<=0 || index>=WAV_COUNT)
8511 1141201 return;
8512
8513
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5332257 times.
5332270 if(sfx_voice[index]!=-1)
8514 {
8515 13 deallocate_voice(sfx_voice[index]);
8516 13 sfx_voice[index]=-1;
8517 13 }
8518 6473471 }
8519
8520 // Stops SFX played by Hero's item of the given family
8521 133939 void stop_item_sfx(int32_t family)
8522 {
8523 133939 int32_t id=current_item_id(family);
8524
8525
2/2
✓ Branch 0 taken 133473 times.
✓ Branch 1 taken 466 times.
133939 if(id<0)
8526 133473 return;
8527
8528 466 stop_sfx(itemsbuf[id].usesound);
8529 133939 }
8530
8531 2359 void kill_sfx()
8532 {
8533
2/2
✓ Branch 0 taken 603904 times.
✓ Branch 1 taken 2359 times.
606263 for(int32_t i=0; i<WAV_COUNT; i++)
8534
2/2
✓ Branch 0 taken 603890 times.
✓ Branch 1 taken 14 times.
603918 if(sfx_voice[i]!=-1)
8535 {
8536 14 deallocate_voice(sfx_voice[i]);
8537 14 sfx_voice[i]=-1;
8538 14 }
8539 2359 }
8540
8541 583538 int32_t pan(int32_t x)
8542 {
8543
1/4
✓ Branch 0 taken 583538 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
583538 switch(pan_style)
8544 {
8545 case 0:
8546 return 128;
8547
8548 case 1:
8549 583538 return vbound((x>>1)+68,0,255);
8550
8551 case 2:
8552 return vbound(((x*3)>>2)+36,0,255);
8553 }
8554
8555 return vbound(x,0,255);
8556 583538 }
8557
8558 /*******************************/
8559 /******* Input Handlers ********/
8560 /*******************************/
8561
8562 21831838 bool joybtn(int32_t b)
8563 {
8564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21831838 times.
21831838 if(b == 0)
8565 return false;
8566
8567 21831838 return joy[joystick_index].button[b-1].b !=0;
8568 21831838 }
8569
8570 const char* joybtn_name(int32_t b)
8571 {
8572 if(b == 0)
8573 return "";
8574
8575 return joy[joystick_index].button[b-1].name;
8576 }
8577
8578 int32_t next_press_key();
8579
8580 int32_t next_press_btn()
8581 {
8582 clear_keybuf();
8583 /*bool b[joy[joystick_index].num_buttons+1];
8584
8585 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8586 b[i]=joybtn(i);*/
8587
8588 //first, we need to wait until they're pressing no buttons
8589 for(;;)
8590 {
8591 if(keypressed())
8592 {
8593 switch(readkey()>>8)
8594 {
8595 case KEY_ESC:
8596 return -1;
8597
8598 case KEY_SPACE:
8599 return 0;
8600 }
8601 }
8602
8603 poll_joystick();
8604 bool done = true;
8605
8606 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8607 {
8608 if(joybtn(i)) done = false;
8609 }
8610
8611 if(done) break;
8612 rest(1);
8613 }
8614
8615 //now, we need to wait for them to press any button
8616 for(;;)
8617 {
8618 if(keypressed())
8619 {
8620 switch(readkey()>>8)
8621 {
8622 case KEY_ESC:
8623 return -1;
8624
8625 case KEY_SPACE:
8626 return 0;
8627 }
8628 }
8629
8630 poll_joystick();
8631
8632 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8633 {
8634 if(joybtn(i)) return i;
8635 }
8636 rest(1);
8637 }
8638 }
8639
8640 168573226 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
8641 {
8642
2/2
✓ Branch 0 taken 162683075 times.
✓ Branch 1 taken 5890151 times.
168573226 bool ret = btn && !flag;
8643
2/2
✓ Branch 0 taken 142452587 times.
✓ Branch 1 taken 26120639 times.
168573226 flag = rawbtn ? *rawbtn : btn;
8644
8645 168573226 return ret;
8646 }
8647 1646643 static bool rButtonPeek(bool btn, bool flag)
8648 {
8649
2/2
✓ Branch 0 taken 1533938 times.
✓ Branch 1 taken 112705 times.
1646643 if(!btn)
8650 {
8651 1533938 return false;
8652 }
8653
2/2
✓ Branch 0 taken 16409 times.
✓ Branch 1 taken 96296 times.
112705 else if(!flag)
8654 {
8655 16409 return true;
8656 }
8657
8658 96296 return false;
8659 1646643 }
8660
8661 // Updated only by keyboard/gamepad.
8662 // If in replay mode, this is set directly by the replay system.
8663 // This should never be read from directly - use control_state instead.
8664 bool raw_control_state[ZC_CONTROL_STATES];
8665
8666 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8667 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8668 // lasts until the next call to load_control_state.
8669 bool control_state[ZC_CONTROL_STATES];
8670 bool disable_control[ZC_CONTROL_STATES];
8671 bool drunk_toggle_state[11];
8672 bool disabledKeys[127];
8673 bool KeyInput[127];
8674 bool KeyPress[127];
8675
8676 bool key_current_frame[127];
8677 bool key_previous_frame[127];
8678
8679 static bool key_system[127];
8680 static bool key_system_previous[127];
8681 static bool key_system_press[127];
8682
8683 bool button_press[ZC_CONTROL_STATES];
8684 bool button_hold[ZC_CONTROL_STATES];
8685
8686 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8687 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8688 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8689 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8690 #define STICK_PRECISION 56 //define your own sensitivity
8691
8692 6820389 void load_control_state()
8693 {
8694 6820389 load_control_called_this_frame = true;
8695
8696
4/4
✓ Branch 0 taken 3949188 times.
✓ Branch 1 taken 2871201 times.
✓ Branch 2 taken 1296436 times.
✓ Branch 3 taken 2652752 times.
6820389 if (replay_get_version() >= 8 && replay_get_version() < 11)
8697 {
8698
2/2
✓ Branch 0 taken 47749536 times.
✓ Branch 1 taken 2652752 times.
50402288 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8699 47749536 down_control_states[i] = raw_control_state[i];
8700 2652752 }
8701
8702
1/2
✓ Branch 0 taken 6820389 times.
✗ Branch 1 not taken.
6820389 if (!replay_is_replaying())
8703 {
8704 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8705 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8706 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8707 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8708 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8709 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8710 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8711 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8712 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8713 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8714 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8715 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8716 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8717 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8718
8719 if(num_joysticks != 0)
8720 {
8721 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8722 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8723 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8724 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8725 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8726 }
8727 else
8728 {
8729 raw_control_state[14] = false;
8730 raw_control_state[15] = false;
8731 raw_control_state[16] = false;
8732 raw_control_state[17] = false;
8733 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8734 }
8735 bool did_bad_cutscene_btn = false;
8736 for(int q = 0; q < 18; ++q)
8737 if(raw_control_state[q] && !active_cutscene.can_button(q))
8738 {
8739 raw_control_state[q] = false;
8740 did_bad_cutscene_btn = true;
8741 }
8742 if(did_bad_cutscene_btn)
8743 active_cutscene.error();
8744 }
8745
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6820386 times.
6820389 if (replay_is_active())
8746 {
8747
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 5805171 times.
6820386 if (replay_get_version() < 3)
8748 1015215 replay_poll();
8749
3/4
✓ Branch 0 taken 5805171 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4043796 times.
✓ Branch 3 taken 1761375 times.
5805171 else if (replay_is_replaying() && replay_get_version() < 6)
8750 1761375 replay_peek_input();
8751
5/6
✓ Branch 0 taken 4043796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3949188 times.
✓ Branch 3 taken 94608 times.
✓ Branch 4 taken 1296436 times.
✓ Branch 5 taken 2652752 times.
4043796 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
8752 2652752 replay_peek_input();
8753
2/2
✓ Branch 0 taken 5715629 times.
✓ Branch 1 taken 1104757 times.
6820386 if (replay_get_version() == 8)
8754 1104757 update_keys();
8755 6820386 }
8756
8757 // Some test replay files were made before a serious input bug was fixed, so instead
8758 // of re-doing them or tossing them out, just check for that zplay version.
8759
3/4
✓ Branch 0 taken 6820383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 6698483 times.
6820389 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8760
2/2
✓ Branch 0 taken 122766894 times.
✓ Branch 1 taken 6820383 times.
129587277 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8761 {
8762 122766894 control_state[i] = raw_control_state[i];
8763
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 73279584 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
122766894 if (botched_input && !control_state[i])
8764 47077142 down_control_states[i] = false;
8765 122766894 }
8766
8767 6820383 button_press[0]=rButton(control_state[0],button_hold[0]);
8768 6820383 button_press[1]=rButton(control_state[1],button_hold[1]);
8769 6820383 button_press[2]=rButton(control_state[2],button_hold[2]);
8770 6820383 button_press[3]=rButton(control_state[3],button_hold[3]);
8771 6820383 button_press[4]=rButton(control_state[4],button_hold[4]);
8772 6820383 button_press[5]=rButton(control_state[5],button_hold[5]);
8773 6820383 button_press[6]=rButton(control_state[6],button_hold[6]);
8774 6820383 button_press[7]=rButton(control_state[7],button_hold[7]);
8775 6820383 button_press[8]=rButton(control_state[8],button_hold[8]);
8776 6820383 button_press[9]=rButton(control_state[9],button_hold[9]);
8777 6820383 button_press[10]=rButton(control_state[10],button_hold[10]);
8778 6820383 button_press[11]=rButton(control_state[11],button_hold[11]);
8779 6820383 button_press[12]=rButton(control_state[12],button_hold[12]);
8780 6820383 button_press[13]=rButton(control_state[13],button_hold[13]);
8781 6820383 button_press[14]=rButton(control_state[14],button_hold[14]);
8782 6820383 button_press[15]=rButton(control_state[15],button_hold[15]);
8783 6820383 button_press[16]=rButton(control_state[16],button_hold[16]);
8784 6820383 button_press[17]=rButton(control_state[17],button_hold[17]);
8785 6820383 }
8786
8787 // Returns true if any game key is pressed. This is needed because keypressed()
8788 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8789 35417576 bool zc_key_pressed()
8790 //may also need to use zc_getrawkey
8791 {
8792
7/10
✓ Branch 0 taken 28696596 times.
✓ Branch 1 taken 6720980 times.
✓ Branch 2 taken 6720980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6720980 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5635187 times.
✓ Branch 7 taken 5635187 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2139141 times.
37556717 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8793
4/6
✓ Branch 0 taken 5635187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5635187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4269298 times.
✓ Branch 5 taken 4269298 times.
5635187 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8794
4/6
✓ Branch 0 taken 4269298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4269298 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2758553 times.
✓ Branch 5 taken 2758553 times.
4269298 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8795
4/6
✓ Branch 0 taken 2758553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2758553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2392721 times.
✓ Branch 5 taken 2392721 times.
2758553 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8796
1/2
✓ Branch 0 taken 2392721 times.
✗ Branch 1 not taken.
2392721 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8797
3/4
✓ Branch 0 taken 2276750 times.
✓ Branch 1 taken 115971 times.
✓ Branch 2 taken 2276750 times.
✗ Branch 3 not taken.
2392721 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8798
3/4
✓ Branch 0 taken 2168833 times.
✓ Branch 1 taken 107917 times.
✓ Branch 2 taken 2168833 times.
✗ Branch 3 not taken.
2276750 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8799
3/4
✓ Branch 0 taken 2154342 times.
✓ Branch 1 taken 14491 times.
✓ Branch 2 taken 2154342 times.
✗ Branch 3 not taken.
2168833 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8800
3/4
✓ Branch 0 taken 2141764 times.
✓ Branch 1 taken 12578 times.
✓ Branch 2 taken 2141764 times.
✗ Branch 3 not taken.
2154342 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8801
3/4
✓ Branch 0 taken 2140020 times.
✓ Branch 1 taken 1744 times.
✓ Branch 2 taken 2140020 times.
✗ Branch 3 not taken.
2141764 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8802
3/4
✓ Branch 0 taken 2139947 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 2139947 times.
✗ Branch 3 not taken.
2140020 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8803
3/4
✓ Branch 0 taken 2139160 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 2139160 times.
✗ Branch 3 not taken.
2139947 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8804
2/4
✓ Branch 0 taken 2139160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2139160 times.
✗ Branch 3 not taken.
2139160 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8805
2/2
✓ Branch 0 taken 2139141 times.
✓ Branch 1 taken 19 times.
2139160 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8806 63389953 return true;
8807
8808 2139141 return false;
8809 8135902 }
8810
8811 133855366 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8812 {
8813 133855366 bool ret = false, drunkstate = false, rawret = false;
8814 133855366 bool* flag = &down_control_states[btn];
8815
2/7
✓ Branch 0 taken 125710970 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 8144396 times.
133855366 switch(btn)
8816 {
8817 case btnF12:
8818 ret = zc_getkey(KEY_F12, ignoreDisable);
8819 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8820 eatEntirely = false;
8821 break;
8822 case btnF11:
8823 ret = zc_getkey(KEY_F11, ignoreDisable);
8824 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8825 eatEntirely = false;
8826 break;
8827 case btnF5:
8828 ret = zc_getkey(KEY_F5, ignoreDisable);
8829 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8830 eatEntirely = false;
8831 break;
8832 case btnQ:
8833 ret = zc_getkey(KEY_Q, ignoreDisable);
8834 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8835 eatEntirely = false;
8836 break;
8837 case btnI:
8838 ret = zc_getkey(KEY_I, ignoreDisable);
8839 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8840 eatEntirely = false;
8841 break;
8842 case btnM:
8843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8144396 times.
8144396 if(FFCore.kb_typing_mode) return false;
8844 8144396 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8845 8144396 eatEntirely = false;
8846 8144396 break;
8847 default: //control_state[] index
8848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125710970 times.
125710970 if(FFCore.kb_typing_mode) return false;
8849
5/6
✓ Branch 0 taken 125237516 times.
✓ Branch 1 taken 473454 times.
✓ Branch 2 taken 2326796 times.
✓ Branch 3 taken 122910720 times.
✓ Branch 4 taken 2326796 times.
✗ Branch 5 not taken.
125710970 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8850
2/2
✓ Branch 0 taken 6790818 times.
✓ Branch 1 taken 118920152 times.
125710970 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8851
4/4
✓ Branch 0 taken 113310335 times.
✓ Branch 1 taken 12400635 times.
✓ Branch 2 taken 5048 times.
✓ Branch 3 taken 12395587 times.
138111605 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8852 125710970 rawret = raw_control_state[btn];
8853 125710970 }
8854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133855366 times.
133855366 assert(flag);
8855
2/2
✓ Branch 0 taken 86402391 times.
✓ Branch 1 taken 47452975 times.
133855366 if(press)
8856 {
8857
2/2
✓ Branch 0 taken 1646643 times.
✓ Branch 1 taken 45806332 times.
47452975 if(peek)
8858 1646643 ret = rButtonPeek(ret, *flag);
8859
3/4
✓ Branch 0 taken 45806332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26120639 times.
✓ Branch 3 taken 19685693 times.
45806332 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
8860 26120639 else ret = rButton(ret, *flag, &rawret);
8861 47452975 }
8862
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133855366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133855366 if(eatEntirely && ret) control_state[btn] = false;
8863
3/4
✓ Branch 0 taken 101223509 times.
✓ Branch 1 taken 32631857 times.
✓ Branch 2 taken 101223509 times.
✗ Branch 3 not taken.
133855366 if(drunk && drunkstate) ret = !ret;
8864 133855366 return ret;
8865 133855366 }
8866
8867 6586646 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8868 {
8869 6586646 byte ret = 0;
8870
2/2
✓ Branch 0 taken 4937925 times.
✓ Branch 1 taken 1648721 times.
6586646 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8871
2/2
✓ Branch 0 taken 6586084 times.
✓ Branch 1 taken 562 times.
6586646 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8872
2/2
✓ Branch 0 taken 6586209 times.
✓ Branch 1 taken 437 times.
6586646 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8873
2/2
✓ Branch 0 taken 6586209 times.
✓ Branch 1 taken 437 times.
6586646 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8874
2/2
✓ Branch 0 taken 6586209 times.
✓ Branch 1 taken 437 times.
6586646 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8875
2/2
✓ Branch 0 taken 6586209 times.
✓ Branch 1 taken 437 times.
6586646 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8876
2/2
✓ Branch 0 taken 6586209 times.
✓ Branch 1 taken 437 times.
6586646 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8877
2/2
✓ Branch 0 taken 6586209 times.
✓ Branch 1 taken 437 times.
6586646 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8878 6586646 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8879 }
8880
8881 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8882 {
8883 1114 return intbtn&vals;
8884 }
8885
8886 1578518 bool Up()
8887 {
8888 1578518 return getInput(btnUp);
8889 }
8890 100557 bool Down()
8891 {
8892 100557 return getInput(btnDown);
8893 }
8894 192956 bool Left()
8895 {
8896 192956 return getInput(btnLeft);
8897 }
8898 217499 bool Right()
8899 {
8900 217499 return getInput(btnRight);
8901 }
8902 112761 bool cAbtn()
8903 {
8904 112761 return getInput(btnA);
8905 }
8906 1333347 bool cBbtn()
8907 {
8908 1333347 return getInput(btnB);
8909 }
8910 bool cSbtn()
8911 {
8912 return getInput(btnS);
8913 }
8914 46682 bool cLbtn()
8915 {
8916 46682 return getInput(btnL);
8917 }
8918 46682 bool cRbtn()
8919 {
8920 46682 return getInput(btnR);
8921 }
8922 bool cPbtn()
8923 {
8924 return getInput(btnP);
8925 }
8926 bool cEx1btn()
8927 {
8928 return getInput(btnEx1);
8929 }
8930 bool cEx2btn()
8931 {
8932 return getInput(btnEx2);
8933 }
8934 bool cEx3btn()
8935 {
8936 return getInput(btnEx3);
8937 }
8938 bool cEx4btn()
8939 {
8940 return getInput(btnEx4);
8941 }
8942 bool AxisUp()
8943 {
8944 return getInput(btnAxisUp);
8945 }
8946 bool AxisDown()
8947 {
8948 return getInput(btnAxisDown);
8949 }
8950 bool AxisLeft()
8951 {
8952 return getInput(btnAxisLeft);
8953 }
8954 bool AxisRight()
8955 {
8956 return getInput(btnAxisRight);
8957 }
8958
8959 bool cMbtn()
8960 {
8961 return getInput(btnM);
8962 }
8963 bool cF12()
8964 {
8965 return getInput(btnF12);
8966 }
8967 bool cF11()
8968 {
8969 return getInput(btnF11);
8970 }
8971 bool cF5()
8972 {
8973 return getInput(btnF5);
8974 }
8975 bool cQ()
8976 {
8977 return getInput(btnQ);
8978 }
8979 bool cI()
8980 {
8981 return getInput(btnI);
8982 }
8983
8984 127703 bool rUp()
8985 {
8986 127703 return getInput(btnUp, true);
8987 }
8988 127609 bool rDown()
8989 {
8990 127609 return getInput(btnDown, true);
8991 }
8992 127557 bool rLeft()
8993 {
8994 127557 return getInput(btnLeft, true);
8995 }
8996 127093 bool rRight()
8997 {
8998 127093 return getInput(btnRight, true);
8999 }
9000 2987 bool rAbtn()
9001 {
9002 2987 return getInput(btnA, true);
9003 }
9004 128823 bool rBbtn()
9005 {
9006 128823 return getInput(btnB, true);
9007 }
9008 6547137 bool rSbtn()
9009 {
9010 6547137 return getInput(btnS, true);
9011 }
9012 8135902 bool rMbtn()
9013 {
9014 8135902 return getInput(btnM, true);
9015 }
9016 126885 bool rLbtn()
9017 {
9018 126885 return getInput(btnL, true);
9019 }
9020 126880 bool rRbtn()
9021 {
9022 126880 return getInput(btnR, true);
9023 }
9024 6464311 bool rPbtn()
9025 {
9026 6464311 return getInput(btnP, true);
9027 }
9028 bool rEx1btn()
9029 {
9030 return getInput(btnEx1, true);
9031 }
9032 bool rEx2btn()
9033 {
9034 return getInput(btnEx2, true);
9035 }
9036 137531 bool rEx3btn()
9037 {
9038 137531 return getInput(btnEx3, true);
9039 }
9040 137531 bool rEx4btn()
9041 {
9042 137531 return getInput(btnEx4, true);
9043 }
9044 bool rAxisUp()
9045 {
9046 return getInput(btnAxisUp, true);
9047 }
9048 bool rAxisDown()
9049 {
9050 return getInput(btnAxisDown, true);
9051 }
9052 bool rAxisLeft()
9053 {
9054 return getInput(btnAxisLeft, true);
9055 }
9056 bool rAxisRight()
9057 {
9058 return getInput(btnAxisRight, true);
9059 }
9060
9061 bool rF11()
9062 {
9063 return getInput(btnF11, true);
9064 }
9065 bool rQ()
9066 {
9067 return getInput(btnQ, true);
9068 }
9069 bool rI()
9070 {
9071 return getInput(btnI, true);
9072 }
9073
9074 16393437 bool DrunkUp()
9075 {
9076 16393437 return getInput(btnUp, false, true);
9077 }
9078 15266683 bool DrunkDown()
9079 {
9080 15266683 return getInput(btnDown, false, true);
9081 }
9082 9597729 bool DrunkLeft()
9083 {
9084 9597729 return getInput(btnLeft, false, true);
9085 }
9086 8331237 bool DrunkRight()
9087 {
9088 8331237 return getInput(btnRight, false, true);
9089 }
9090 7130834 bool DrunkcAbtn()
9091 {
9092 7130834 return getInput(btnA, false, true);
9093 }
9094 7015929 bool DrunkcBbtn()
9095 {
9096 7015929 return getInput(btnB, false, true);
9097 }
9098 6417281 bool DrunkcEx1btn()
9099 {
9100 6417281 return getInput(btnEx1, false, true);
9101 }
9102 6417301 bool DrunkcEx2btn()
9103 {
9104 6417301 return getInput(btnEx2, false, true);
9105 }
9106 bool DrunkcSbtn()
9107 {
9108 return getInput(btnS, false, true);
9109 }
9110 bool DrunkcMbtn()
9111 {
9112 return getInput(btnM, false, true);
9113 }
9114 bool DrunkcLbtn()
9115 {
9116 return getInput(btnL, false, true);
9117 }
9118 bool DrunkcRbtn()
9119 {
9120 return getInput(btnR, false, true);
9121 }
9122 bool DrunkcPbtn()
9123 {
9124 return getInput(btnP, false, true);
9125 }
9126
9127 bool DrunkrUp()
9128 {
9129 return getInput(btnUp, true, true);
9130 }
9131 bool DrunkrDown()
9132 {
9133 return getInput(btnDown, true, true);
9134 }
9135 bool DrunkrLeft()
9136 {
9137 return getInput(btnLeft, true, true);
9138 }
9139 bool DrunkrRight()
9140 {
9141 return getInput(btnRight, true, true);
9142 }
9143 5376068 bool DrunkrAbtn()
9144 {
9145 5376068 return getInput(btnA, true, true);
9146 }
9147 5391726 bool DrunkrBbtn()
9148 {
9149 5391726 return getInput(btnB, true, true);
9150 }
9151 71669 bool DrunkrEx1btn()
9152 {
9153 71669 return getInput(btnEx1, true, true);
9154 }
9155 71662 bool DrunkrEx2btn()
9156 {
9157 71662 return getInput(btnEx2, true, true);
9158 }
9159 bool DrunkrEx3btn()
9160 {
9161 return getInput(btnEx3, true, true);
9162 }
9163 bool DrunkrEx4btn()
9164 {
9165 return getInput(btnEx4, true, true);
9166 }
9167 bool DrunkrSbtn()
9168 {
9169 return getInput(btnS, true, true);
9170 }
9171 bool DrunkrMbtn()
9172 {
9173 return getInput(btnM, true, true);
9174 }
9175 6046715 bool DrunkrLbtn()
9176 {
9177 6046715 return getInput(btnL, true, true);
9178 }
9179 6043333 bool DrunkrRbtn()
9180 {
9181 6043333 return getInput(btnR, true, true);
9182 }
9183 bool DrunkrPbtn()
9184 {
9185 return getInput(btnP, true, true);
9186 }
9187
9188 8494 void eat_buttons()
9189 {
9190 8494 getInput(btnA, true, false, true);
9191 8494 getInput(btnB, true, false, true);
9192 8494 getInput(btnS, true, false, true);
9193 8494 getInput(btnM, true, false, true);
9194 8494 getInput(btnL, true, false, true);
9195 8494 getInput(btnR, true, false, true);
9196 8494 getInput(btnP, true, false, true);
9197 8494 getInput(btnEx1, true, false, true);
9198 8494 getInput(btnEx2, true, false, true);
9199 8494 getInput(btnEx3, true, false, true);
9200 8494 getInput(btnEx4, true, false, true);
9201 8494 }
9202
9203 // Is true for the _first frame_ of a key press.
9204 // But! it is possible that a script manually sets the value of KeyPress,
9205 // in which case it will be restored to the "true" value based on `key_current_frame`
9206 // and `key_previous_frame` on the next frame.
9207 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9208 {
9209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9211 {
9212 case KEY_F7:
9213 case KEY_F8:
9214 case KEY_F9:
9215 return KeyPress[k];
9216
9217 default:
9218
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9219 }
9220 14 }
9221
9222 // Is true for _every frame_ a key is held down.
9223 // But! it is possible that a script manually sets the value of KeyInput,
9224 // in which case it will be restored to the "true" value based on `key_current_frame`
9225 // on the next frame.
9226 bool zc_getkey(int32_t k, bool ignoreDisable)
9227 {
9228 if(ignoreDisable) return KeyInput[k];
9229 switch(k)
9230 {
9231 case KEY_F7:
9232 case KEY_F8:
9233 case KEY_F9:
9234 return KeyInput[k];
9235
9236 default:
9237 return KeyInput[k] && !disabledKeys[k];
9238 }
9239 }
9240
9241 // Reads (and then clears) the current frame key state directly.
9242 // Scripts can also modify `key_current_frame`.
9243 202 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9244 {
9245
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 200 times.
202 if(zc_getrawkey(k, ignoreDisable))
9246 {
9247 2 _key[k]=key[k]=key_current_frame[k]=0;
9248 2 return true;
9249 }
9250 200 _key[k]=key[k]=key_current_frame[k]=0;
9251 200 return false;
9252 202 }
9253
9254 // Reads the current frame key state directly.
9255 // Scripts can also modify `key_current_frame`.
9256 55357215 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9257 {
9258
2/2
✓ Branch 0 taken 47221285 times.
✓ Branch 1 taken 8135930 times.
55357215 if(ignoreDisable) return key_current_frame[k];
9259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8135930 times.
8135930 switch(k)
9260 {
9261 case KEY_F7:
9262 case KEY_F8:
9263 case KEY_F9:
9264 return key_current_frame[k];
9265
9266 default:
9267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8135930 times.
8135930 return key_current_frame[k] && !disabledKeys[k];
9268 }
9269 55357215 }
9270
9271 // Only used for a handful of keys, like tilde and Function keys.
9272 // This state is never read within the game.
9273 // It exists so that all keyboard input still functions during replay,
9274 // without inadvertently doing things like toggling throttling if the player
9275 // presses ~
9276 16271903 bool zc_get_system_key(int32_t k)
9277 {
9278 16271903 return key_system[k];
9279 }
9280
9281 // True for the _first_ frame of a key press.
9282 73223118 bool zc_read_system_key(int32_t k)
9283 {
9284 73223118 return key_system_press[k];
9285 }
9286
9287 1033259554 bool is_system_key(int32_t k)
9288 {
9289
2/2
✓ Branch 0 taken 960036436 times.
✓ Branch 1 taken 73223118 times.
1033259554 switch (k)
9290 {
9291 case KEY_BACKQUOTE:
9292 case KEY_CLOSEBRACE:
9293 case KEY_END:
9294 case KEY_HOME:
9295 case KEY_OPENBRACE:
9296 case KEY_PGDN:
9297 case KEY_PGUP:
9298 case KEY_TAB:
9299 case KEY_TILDE:
9300 73223118 return true;
9301 }
9302 960036436 return is_Fkey(k);
9303 1033259554 }
9304
9305 8135902 void update_system_keys()
9306 {
9307
2/2
✓ Branch 0 taken 1033259554 times.
✓ Branch 1 taken 8135902 times.
1041395456 for (int32_t q = 0; q < 127; ++q)
9308 {
9309
2/2
✓ Branch 0 taken 170853942 times.
✓ Branch 1 taken 862405612 times.
1033259554 if (!is_system_key(q))
9310 862405612 continue;
9311
9312 170853942 key_system[q] = key[q];
9313
1/2
✓ Branch 0 taken 170853942 times.
✗ Branch 1 not taken.
170853942 key_system_press[q] = key_system[q] && !key_system_previous[q];
9314 170853942 key_system_previous[q] = key_system[q];
9315 170853942 }
9316 8135902 }
9317
9318 9240659 void update_keys()
9319 {
9320
2/2
✓ Branch 0 taken 1173563693 times.
✓ Branch 1 taken 9240659 times.
1182804352 for (int32_t q = 0; q < 127; ++q)
9321 {
9322 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9323
1/2
✓ Branch 0 taken 1173563693 times.
✗ Branch 1 not taken.
1173563693 if (!replay_is_replaying())
9324 key_current_frame[q] = key[q];
9325
9326
2/2
✓ Branch 0 taken 1164896494 times.
✓ Branch 1 taken 8667199 times.
1173563693 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9327 1173563693 KeyInput[q] = key_current_frame[q];
9328 1173563693 key_previous_frame[q] = key_current_frame[q];
9329 1173563693 }
9330 9240659 }
9331
9332 bool zc_disablekey(int32_t k, bool val)
9333 {
9334 switch(k)
9335 {
9336 case KEY_F7:
9337 case KEY_F8:
9338 case KEY_F9:
9339 return false;
9340
9341 default:
9342 disabledKeys[k] = val;
9343 return true;
9344 }
9345 }
9346
9347 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9348 {
9349 timer=timer;
9350 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9351 }
9352